Reputation: 601
I'm trying to do something I thought would be simple. Query SimpleGeo, take the json and show the points on a google map.
The logic is as follows: User views a page about a location stored in the Django DB with a simple google map. That map has one point showing the location. User clicks show hotels jQuery retrives json from SimpleGeo for a given lat/long jQuery updates google map with points for hotes around that location.
Problems I'm having; The json comes back with several entires. I've tried several looping functions but couldn't get anything but null. So then I just say json_ob[0] and I get one listing, but I can't get the cords from the json and show them on the map. Gmaps keeps compaining about the cords are not vaild. I've used alert() to check them but they seem to be the same format as the initial ones for the map.
I've also tried processing the json in my view and sending just the lat and long to the template but that doesn't seem to work either.
A link to a example or tutorial would be great.
I have here some
var obj = jQuery.parseJSON('{{ near_geo|safe }}');
cords = obj.geometry.coordinates
cords_array = cords.toString().split(',')
lng = cords_array[0];
lat = cords_array[1];
var marker = new google.maps.Marker({
map: map,
position: [lat , lng]
});
That produces: Invalid value for property : 32.929272,-83.741676
If I could just get one to show up then I can loop and get the rest.
Upvotes: 0
Views: 629
Reputation: 24823
try to replace
var marker = new google.maps.Marker({
map: map,
position: [lat , lng]
});
with
var marker = new google.maps.Marker({
map: map,
position: new google.maps.LatLng(lat, lng);
});
Upvotes: 2