Javascript 谷歌地图Api可以';带Json的t显示标记(v3)

Javascript 谷歌地图Api可以';带Json的t显示标记(v3),javascript,json,google-maps,google-maps-api-3,Javascript,Json,Google Maps,Google Maps Api 3,我用Json创建了谷歌地图,并使用了数据库postgresql 这是我的密码 <script type="text/javascript"> var map; var national = [{"lng":"-6.173319","city":"JAKARTA","lat":"106.818672"}]; function initialize() { var mapOptions = { center: new google.maps.LatLn

我用Json创建了谷歌地图,并使用了数据库postgresql

这是我的密码

<script type="text/javascript">
  var map;

  var national = [{"lng":"-6.173319","city":"JAKARTA","lat":"106.818672"}];

  function initialize() {
    var mapOptions = {
      center: new google.maps.LatLng(-0.789275,113.921327),
      zoom: 5,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var infoWindow = new google.maps.InfoWindow();
    var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);

  $.getJSON('json_city.json', function(data) { 
    $.each( data.national, function(index, item) {
      var myLatlng = new google.maps.LatLng(item.lat, item.lng);
      alert(myLatlng);
      var marker = new google.maps.Marker({
        position: myLatlng,
        map: map,
        title: "text "+item.city
      });
    });
  });

  // Initialize the map
  }
  google.maps.event.addDomListener(window, 'load', initialize);

</script>

var映射;
var national=[{“lng”:“-6.173319”,“城市”:“雅加达”,“拉丁美洲”:“106.818672”}];
函数初始化(){
变量映射选项={
中心:新的google.maps.LatLng(-0.789275113.921327),
缩放:5,
mapTypeId:google.maps.mapTypeId.ROADMAP
};
var infoWindow=new google.maps.infoWindow();
var map=new google.maps.map(document.getElementById(“map_canvas”),mapOptions);
$.getJSON('json_city.json',函数(数据){
美元(数据、国家、职能(索引、项目){
var mylatng=new google.maps.LatLng(item.lat,item.lng);
警报(myLatlng);
var marker=new google.maps.marker({
职位:myLatlng,
地图:地图,
标题:“文本”+item.city
});
});
});
//初始化映射
}
google.maps.event.addDomListener(窗口“加载”,初始化);

Lat和长期使用的字符类型(文本)。我的地图可以显示,但我的标记不能显示

谷歌地图需要LatLng构造函数的坐标是数字,而不是字符串。尝试:

var myLatlng = new google.maps.LatLng(parseFloat(item.lat), parseFloat(item.lng));

我试过了,但没有成功。我已经签入了console.log(“item.lat”);和控制台日志(“item.lng”);我的谷歌浏览器也不能显示日志@邓肯国家数据是什么样子的?您已经在JS顶部硬编码了
var national
,但是没有使用它
lat
lng
是向后的(应该是
“lat”:“-6.173319”,“lng”:“106.818672”
)。()感谢您的更正@geocodezip