views:

47

answers:

1

Hi, a very simple question I am sure just the brain isn't working this morning.

I have the folowing code I am using with JQuery and the Google Maps v3 API. I basically am trying to refresh a map with new search results once it has been dragged to a new location.

google.maps.event.addListener(
   map, 'dragend', function() {
      var newlatlng = map.getCenter();
      $('#venue-list-container').load('/maps/geoMap.php?',{latlon: newlatlng});
});

However I can't find what to use in the parameters after the url to post the newlatlng value (latlon: newlatlng). At the moment it doesn't work

A: 

Use post?

var lat = newlatlng.lat();
var lng = newlatlng.lng();
$('#venue-list-container').post('/maps/geoMap.php?', 
                                    {latitude: lat, longitude: lng});

The $.post function calls the PHP script, sending along the coordinates. The PHP script is able to retrieve these coordinates by referring to them within the $_POST array. Like $_POST['latitude']

heffaklump
Hi, a sort of hybrid seemed to work, if I used the lat and lng from your code above with the line $('#venue-list-container').load('/maps/geoMap.php',{lat:lat, lon:lng}); in my code it appeared to work all ok. Would the original newlatlng have been messing it up? If I alerted it it displayed all OK?
bateman_ap
The newlatlng was probably ok. But it depends on how geoMap.php handles incoming data. Can it handle class GLatLng?
heffaklump