Google maps jQuery gMap插件->;动态构建选项的问题
使用jQuery插件gMap从 我不明白为什么第一个(被注释掉的)调用能够正确地显示地图 但是第二个(动态构建的)不起作用。第二张显示了一张地图,但没有标记,并且一直缩小Google maps jQuery gMap插件->;动态构建选项的问题,google-maps,jquery-plugins,Google Maps,Jquery Plugins,使用jQuery插件gMap从 我不明白为什么第一个(被注释掉的)调用能够正确地显示地图 但是第二个(动态构建的)不起作用。第二张显示了一张地图,但没有标记,并且一直缩小 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>GMap Test</title> <script src="/asse
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>GMap Test</title>
<script src="/assets/js/jquery-1.6.min.js" type="text/javascript"></script>
<script type="text/javascript" src="http://maps.google.com/maps?file=api&v=2&key=My_API_Key"></script>
<script type="text/javascript" src="/assets/js/jquery.gmap-1.1.0.js"></script>
<script>
$(document).ready(function(){
/*
$("#course_map").gMap({controls: true,
scrollwheel: true,
markers: [{latitude: 44.5643,
longitude:-88.1033,
html: "Radisson/Oneida Casino<br />2040 Airport Drive<br />Green Bay, WI",
icon: {image: "/images/gmap_pin_orange.png",
iconsize: [26, 46],
iconanchor: [12,46],
infowindowanchor: [12, 0]
}
},
{latitude: 44.2674,
longitude:-88.4383,
html: "Radisson Paper Valley Hotel<br />333 W. College Avenue<br />Appleton, WI",
icon: {image: "/images/gmap_pin_orange.png",
iconsize: [26, 46],
iconanchor: [12,46],
infowindowanchor: [12, 0]
}
}
],
zoom: 8
}
);
*/
var markers = 'markers: [{latitude: 44.5643, '+
' longitude:-88.1033, '+
' html: "Radisson/Oneida Casino<br />2040 Airport Drive<br />Green Bay, WI", '+
' icon: {image: "/images/gmap_pin_orange.png", iconsize: [26, 46], '+
' iconanchor: [12,46], '+
' infowindowanchor: [12, 0] '+
' } '+
' }, '+
' {latitude: 44.2674, '+
' longitude:-88.4383, '+
' html: "Radisson Paper Valley Hotel<br />333 W. College Avenue<br />Appleton, WI", '+
' icon: {image: "/images/gmap_pin_orange.png", iconsize: [26, 46], '+
' iconanchor: [12,46], '+
' infowindowanchor: [12, 0] '+
' } '+
' },';
markers = markers.slice(0, -1);
markers = '{controls: true, scrollwheel: true, ' + markers + '], zoom: 8}';
$("#course_map").gMap(markers);
});
</script>
</head>
<body>
<div id="course_map" style="height:297px; width:380px;border: 2px solid #666;"></div>
</body>
</html>
GMap测试
$(文档).ready(函数(){
/*
$(“#课程地图”).gMap({controls:true,
滚轮:对,
标记:[{纬度:44.5643,
经度:-88.1033,
html:“威斯康星州绿湾Radisson/Oneida赌场
2040机场大道
”,
图标:{image:“/images/gmap_pin_orange.png”,
iconsize:[26,46],
iconanchor:[12,46],
infowindowanchor:[12,0]
}
},
{纬度:44.2674,
经度:-88.4383,
html:“雷迪森纸谷酒店
威斯康星州阿普尔顿大学大道西333号
”,
图标:{image:“/images/gmap_pin_orange.png”,
iconsize:[26,46],
iconanchor:[12,46],
infowindowanchor:[12,0]
}
}
],
缩放:8
}
);
*/
var markers='markers:[{纬度:44.5643,'+
'经度:-88.1033,'+
'html:“雷迪森/Oneida赌场
2040机场大道
威斯康星州绿湾”+
'图标:{image:“/images/gmap_pin_orange.png”,图标:[26,46],'+
“iconanchor:[12,46],”+
'infowindowanchor:[12,0]'+
' } '+
' }, '+
{纬度:44.2674,'+
'经度:-88.4383,'+
'html:“雷迪森纸谷酒店
威斯康星州阿普尔顿大学大道西333号
”+
'图标:{image:“/images/gmap_pin_orange.png”,图标:[26,46],'+
“iconanchor:[12,46],”+
'infowindowanchor:[12,0]'+
' } '+
' },';
markers=markers.slice(0,-1);
markers='{controls:true,scrollwheel:true,'+markers+'],zoom:8}';
$(“课程地图”).gMap(标记);
});
这里有人可以帮忙吗?我正在通过ajax调用在成功函数中构建标记,如下所示:
success: function(data) {
var markers = { controls: true, scrollwheel: true, markers: [], zoom: 8 };
$.each(data["events"], function(id, event) {
// .. do other stuff with the data
if(showmap) {
// add location to maps list prevent multiples
marker1 = { latitude: event['LocLatitude'],
longitude:event['LocLongitude'],
html: '"'+event['LocName']+'<br />'+event['LocAddress']+'<br />'+event['LocCity']+', '+event['LocState']+'"',
icon:{image: "/images/gmap_pin_orange.png",
iconsize: [26, 46],
iconanchor: [12,46],
infowindowanchor: [12, 0]
}
};
markers.markers.push(marker1);
} // if(showmap)
} // $.each(data["events"]
}, // success:
$("#course_map").gMap(markers);