Skip to content Skip to sidebar Skip to footer

Displaying Marker With Latlong Json Data In Biostall-google-maps-v3 Api Library Issue

i have a simple AJAX that will get all data from MYSQL with my controller then display all data with its latitude and longitude when searched: $(document).ready(function () { $

Solution 1:

The problem is google.maps.LatLng is expecting two numbers and you are passing it a string from your database (assuming searchMapDataResult['latlong'] is returning a comma delimited string). So you will need to

  1. Split the latitude and longitude
  2. Convert them into numbers
  3. Generate the google.maps.LatLng

Like this:

var latLngArray = searchMapDataResult['latlong'].split(',');
var latitude = parseFloat(latLngArray[0]);
var longitude = parseFloat(latLngArray[1]);
var myLatLong = new google.maps.LatLng(latitude,longitude );

Post a Comment for "Displaying Marker With Latlong Json Data In Biostall-google-maps-v3 Api Library Issue"