So basically when you go to that link, the map is supposed to show all the markers that relate to the regions, but they don’t, if you want to see it working as it is now on the live server which is fine, then just take the number 2 away from result2.php
Hey multichild, there’s a problem with undefined variables which is breaking the page:
// var scountry = '58';
//var sregion = '
Notice: Undefined variable: regionData3 in **path removed**\result2.php on line 852
';
var data = {
selectCountry: 58,
selectRegion:
Notice: Undefined variable: selectRegion in **path removed**\result2.php on line 856
null };
If you want to see the value of a JS variable at a certain point in time, you can use the dev tools (Chrome and FF are similar, not sure about IE these days). The easiest way would be to put a breakpoint on one of the lines (such as where the Ajax call is made) and the debugger will stop at that point and allow you to inspect the value of the variables:
Ah right, the first ones are commented out, but I just took those lines away and added the variable to the top of the page and that seems to have sorted out the issue of the map not showing up first. So that’s one thing sorted
I have written extensively on Google Maps using code generated by SAS programming language. In particular, the following blog posts are directly related to the topic of outputting markers to Google Map:
- Spice up SAS output with live Google maps - blogs.sas.com/content/sgf/2014/06/06/spice-up-sas-output-with-live-google-maps/
- Live Google maps in SAS – multiple markers - blogs.sas.com/content/sgf/2014/07/24/live-google-maps-in-sas-multiple-markers/
- SAS ODS destination - Google maps - blogs.sas.com/content/sgf/2015/06/05/sas-ods-destination-google-maps/
- Integrating SAS reports with Google maps: two-pane solution
All my Google Map - related blog posts can be found at SAS blog - TAG: GOOGLE MAPS
Looking at your WIP page, there’s now a small bug with the callback for the Ajax request:
$.get('phpsqlajax_genxml2.php', data, function(response) {
var xml = data.responseXML;
var markers = xml.documentElement.getElementsByTagName("marker");
//...
needs to be:
$.get('phpsqlajax_genxml2.php', data, function(response) {
var markers = response.getElementsByTagName("marker");
//...
that looks to be what is preventing the markers being added.
morning,
I’m still working on the same page in the live area and made the change and unfortunately still no workio.
Thanks though fretburner and noppy for helping out with this.
I had a look at the source code with 2 regions selected and I could see
var data = {
selectCountry: 58,
selectRegion: [436,446]
};
And I’m only playing mind as I might be wrong, but I took [436,446]m and pasted it onto the code below in the next page and I got an error, so is that something maybe
$selectCountry = isset($_GET['selectCountry']) ? $_GET['selectCountry'] : null;
$selectRegion = [436,446];
I then tried below and that didn’t work either
$selectRegion = array(436,446);
Morning,
Are you using your browser’s console to check for errors? Because I’m seeing another now using the result2.php page:
Uncaught ReferenceError: scountry is not defined
Which is pointing at line 590, which has this code:
var html = "<b>" + address + "</b><br/><br/><a href='result.php?regions[]="+resort+"&Country="+scountry+"'>Click here to view " + address + " hotels</a>";
Here, scountry
should be replaced with data.selectCountry
.
I also notice that further up the script, you’ve got this:
var data = {
selectCountry: 58,
selectRegion: "" };
See that selectRegion
is being output as an empty string for some reason. Could you show the code from result2.php
that deals with this value?
Ah ha, crackalacking…
Adding
var scountry = '<?php echo $_GET['Country'];?>';
To clear the error, made it work, and works perfectly lol
Oh the relief, I’m going to stick the kettle on lol
Have a look, what you think?
Sorry rushed then, have changed it now to the way you suggested.
took my man handling away and added your better way in, and it works perfectly.
Thanks again fretburner
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.