javascript - Google maps api json ajax -- markers not showing up -
i have coded part fetch josn of markers , iterate through them. reason markers not showing on map. can me find mistake.
$.ajax({ url: "get_markers.php", type: 'post', datatype: 'json', data: {'address':address}, success: function (html, status, response) { $.each(html, function(i, place) { alert(json.stringify(place.lat)+","+json.stringify(place.lng)); latlng = new google.maps.latlng(json.stringify(place.lat), json.stringify(place.lng)); marker = new google.maps.marker({ position: latlng, map: map //title: data.title }); }); } i have defined map variable, latlng , marker. right lat , lang values when alert(..).
thanks
why converting string.
the constructor documentation
latlng(lat:number, lng:number, nowrap?:boolean) change
latlng = new google.maps.latlng(json.stringify(place.lat), json.stringify(place.lng)); to
latlng = new google.maps.latlng(place.lat,place.lng);
Comments
Post a Comment