如何将lat值放在标记内?

时间:2014-06-05 11:21:33

标签: javascript google-maps

$.getJSON('map_points.json', function(data) { 
  $.each( data.points, function(i, value) {

    var marker = new google.maps.Marker({
      position: new google.maps.LatLng(value.lat, value.lon),
      map: map,
      title: " text " +  value.lat
    });
  });
}); 

我使用map_points.json文件中的latlon值制作了标记。现在,我想在我的谷歌地图中的每个制作者中显示data_points.json值。

1 个答案:

答案 0 :(得分:0)

试试这个:

$.getJSON('map_points.json', function(data) { 
        $.each( data.points, function(i, value) {

            var marker = new google.maps.Marker({
            position: new google.maps.LatLng(value.lat, value.lon),
            map: map,
            title: " Latitude: " +  value.lat+" Longiude: "+value.lon//here is the difference
            });

            //add info window
            var iw = new google.maps.InfoWindow({
                     content:  "Latitude: " +  value.lat+" Longiude: "+value.lon
             });
             google.maps.event.addListener(marker, "click", function (e) { iw.open(map, this); });
        });

});