简体   繁体   English

JSON数据未显示在Google地图的标记中

[英]JSON Data not appearing on marker in Google map

I want to Load my JSON data to appear on Google map markers. 我想加载JSON数据以显示在Google地图标记上。 I have used Jquery getJSON method to call the JSON data from a server. 我已经使用Jquery getJSON方法从服务器调用JSON数据。 But the map is appearing but not the markers. 但是地图出现了,但标记没有出现。 Here's the codes 这是代码

  var map; function initialize() { var mapProp = { center: new google.maps.LatLng(28.003389000000, -82.429500000000), zoom: 5, mapTypeId: google.maps.MapTypeId.ROADMAP }; map = new google.maps.Map(document.getElementById("map"), mapProp); $.getJSON('http://tripleclickstudio.com/json/file.json?callback=?', function (json1) { $.each(json1.ResponseData, function (key, data) { var latLng = new google.maps.LatLng(data.CoordinateY, data.CoordinateX), marker = new google.maps.Marker({ position: latLng, map: map, title: data.BuildingName }), details = data.BuildingName + ", " + data.Location + "."; }); }); } var infowindow = new google.maps.InfoWindow(); function bindInfoWindow(marker, map, infowindow, strDescription) { google.maps.event.addListener(marker, 'click', function () { infowindow.setContent(strDescription); infowindow.open(map, marker); }); bindInfoWindow(marker, map, infowindow, details); } google.maps.event.addDomListener(window, 'load', initialize); 
 <script src="https://maps.googleapis.com/maps/api/js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="map" style="border: 2px solid #3872ac;"></div> 

this is the link of my JSON file JSON file. 这是我的JSON文件JSON文件的链接。 So, Here's the thing, I want JSON data coordinates to show as a marker in google map. 所以,这就是问题,我希望JSON数据坐标在Google Map中显示为标记。 So, Any so if any one tells me what the mistake i have made and what need to be done to fix this. 因此,如果有人告诉我,我犯了什么错误以及需要采取哪些措施来解决此问题,请联系我们。 Thanks 谢谢

Just remove the ?callback=? 只需删除?callback=? from the json url. 来自json网址。

That syntax is for JSON P , and your file contents are JSON. 该语法适用于JSON P ,您的文件内容为JSON。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM