sepoto Posted April 12, 2012 Share Posted April 12, 2012 // // // // // // // // Ajax returns from PHPxmlhttp.onreadystatechange=function() {if (xmlhttp.readyState==4 && xmlhttp.status==200){var obj = $.parseJSON(xmlhttp.responseText); var tLat = getCookie("tLat");var tLng = getCookie("tLng"); var options = { zoom: 4, center: new google.maps.LatLng(40.7257, -74.0047), mapTypeId: google.maps.MapTypeId.ROADMAP}; // Creating the map var map = new google.maps.Map(document.getElementById('map'), options); alert(obj[0][1]+','+obj[0][2]); //var myLatLng = new google.maps.LatLng(40.7257, -74.0047);var myLatLng = new google.maps.LatLng(String(obj[0][1]), String(obj[0][2])); var marker = new google.maps.Marker({ position: myLatLng, map: map }); $('#map').show();}}// // // // // // // // My alert is showing "-84.3132324,34.0393598". Uncommenting "//var myLatLng = new google.maps.LatLng(40.7257, -74.0047);" shows the marker beautifully. The current "var myLatLng = new google.maps.LatLng(String(obj[0][1]), String(obj[0][2]));" will not show me the marker. I for the life of me can not figure out why yet. ????????????????????????????????? Thanks a bunch! Link to comment Share on other sites More sharing options...
justsomeguy Posted April 12, 2012 Share Posted April 12, 2012 Is it because you're casting the numbers to strings? Link to comment Share on other sites More sharing options...
sepoto Posted April 12, 2012 Author Share Posted April 12, 2012 I don't know what to cast them to or how. I would be really stoked to get some help out with this! Link to comment Share on other sites More sharing options...
thescientist Posted April 12, 2012 Share Posted April 12, 2012 what he is saying is you are casting them to strings, by using the String Constructor String(obj[0][1]), String(obj[0][2]) so try not doing that new google.maps.LatLng(obj[0][1], obj[0][2]); Link to comment Share on other sites More sharing options...
sepoto Posted April 12, 2012 Author Share Posted April 12, 2012 This: var myLatLng = new google.maps.LatLng(obj[0][1], obj[0][2]); For some reason does not show the marker either. Those values started as floating point values in my MySQL database. They get retrieved and converted to a JSON array which is decoded into the array obj. What happens from there I don't know all the details yet. I just know that the constructor is not accepting them. Link to comment Share on other sites More sharing options...
dsonesuk Posted April 12, 2012 Share Posted April 12, 2012 try parseFloat var myLatLng = new google.maps.LatLng(parseFloat(obj[0][1]), parseFloat(obj[0][2)]); Link to comment Share on other sites More sharing options...
sepoto Posted April 12, 2012 Author Share Posted April 12, 2012 I put your line in (with a minor edit ). The code runs with no errors in the console however there is no marker yet. This is a very vexing problem. Link to comment Share on other sites More sharing options...
justsomeguy Posted April 12, 2012 Share Posted April 12, 2012 The lat/long you showed corresponds to a position in Antarctica, is that what you're trying to show? Is the problem just the wrong coordinates? Link to comment Share on other sites More sharing options...
dsonesuk Posted April 12, 2012 Share Posted April 12, 2012 Do you see the same start location everytime? zoom out if you do, i bet you will see the marker now just with Antartica Link to comment Share on other sites More sharing options...
sepoto Posted April 12, 2012 Author Share Posted April 12, 2012 LOL!!!!!!!!!!!!!!!!!!!! Thanks! Today will be a good day! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.