Javascript Google地图标记不是从JSON填充的
我试图用JSON脚本中的多个标记填充Google地图。这张地图效果很好,但是我正在努力让标记显示出来 我尝试过这个方法,但效果相同: 我的JSON:Javascript Google地图标记不是从JSON填充的,javascript,jquery,json,google-maps,google-maps-api-3,Javascript,Jquery,Json,Google Maps,Google Maps Api 3,我试图用JSON脚本中的多个标记填充Google地图。这张地图效果很好,但是我正在努力让标记显示出来 我尝试过这个方法,但效果相同: 我的JSON: {"markers":[ { "latitude":57.7973333, "longitude":12.0502107, "title":"Angered", "content":"Representing :)" }, { "latitude":57.6969943, "longitude":11.9865, "title":"Gothen
{"markers":[ { "latitude":57.7973333, "longitude":12.0502107, "title":"Angered",
"content":"Representing :)" }, { "latitude":57.6969943, "longitude":11.9865,
"title":"Gothenburg", "content":"Swedens second largest city" } ]}
我的HTML:
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="js/jquery.gmap.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
$('.w-map-h').gMap().bind('init', function() {
// This URL won't work on your localhost, so you need to change it
// see http://en.wikipedia.org/wiki/Same_origin_policy
$.getJSON( 'js/mapData.json', function(data) {
$.each( data.markers, function(i, marker) {
$('#w-map-h').gMap('addMarker', {
'position': new google.maps.LatLng(marker.latitude, marker.longitude),
'bounds': true
}).click(function() {
$('.w-map-h').gMap('openInfoWindow', { 'content': marker.content }, this);
});
});
});
});
});
</script>
<div class="w-map">
<div class="w-map-h" style="height: 300px;">
</div>
</div>
jQuery(文档).ready(函数(){
$('.w-map-h').gMap().bind('init',function(){
//此URL在您的本地主机上不起作用,因此您需要更改它
//看http://en.wikipedia.org/wiki/Same_origin_policy
$.getJSON('js/mapData.json',函数(数据){
$.each(data.markers,function(i,marker){
$('w-map-h').gMap('addMarker'{
“位置”:新的google.maps.LatLng(marker.lation,marker.longitude),
“界限”:真
})。单击(函数(){
$('.w-map-h').gMap('openInfoWindow',{'content':marker.content},this);
});
});
});
});
});
jQuery附在后面的页面上
如果我还能做什么,请告诉我
谢谢。我还应该补充一点,数据正在JSON中填充,因为我已经完成了一个console.log,它返回了所需的结果。您正在使用oldschool google maps v2,是这样吗?您正在使用的插件是什么,jQuery有不同的gMap插件吗?Molle博士和我的主题一起出现,所以我只是想把它和这个主题结合起来。我可以改变任何需要的东西@戴维康拉德不是故意的,它带有主题。我需要做什么才能改变它?我应该重新启动并自己安装吗?