Hello Stackoverflowers,
我正在尝试将多个位置和一个圆圈组合在同一个地图中,我仔细看看如何组合两种不同的元素类型,但我还没有发现任何有用的东西。
下面是一些绘制圆圈的示例代码:
<head>
<script
src="http://maps.googleapis.com/maps/api/js?key=AIzaSyDY0kkJiTPVd2U7aTOAwhc9ySH6oHxOIYM&sensor=false">
</script>
<script>
var Hotspot=new google.maps.LatLng( 29.9597675231189 , -93.9675262286223 );
function initialize()
{
var mapProp = {
center:Hotspot,
zoom:7,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("googleMap"),mapProp);
var Circle = new google.maps.Circle({
center:Hotspot,
radius:25000,
strokeColor:"#0000FF",
strokeOpacity:0.8,
strokeWeight:2,
fillColor:"#0000FF",
fillOpacity:0
});
Circle.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="googleMap" style="width:500px;height:380px;"></div>
</body>
</html>
现在举例来说,如果我希望将2个标记放在:
lat 29.937641 long -93.969326 lat 30.063964 long -94.116131
我如何将其纳入上述代码?或者反之亦然,如果我有点数的代码,我将如何合并圆圈元素?
一如既往地感谢您的帮助!
答案 0 :(得分:2)
function initialize()
{
var mapProp = {
center:Hotspot,
zoom:7,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("googleMap"),mapProp);
var marker1=new google.maps.Marker({map:map, position: new google.maps.LatLng(29.937641,-93.969326)});
var marker2=new google.maps.Marker({map:map, position: new google.maps.LatLng(30.063964 .-94.116131)});
var Circle = new google.maps.Circle({
center:Hotspot,
radius:25000,
strokeColor:"#0000FF",
strokeOpacity:0.8,
strokeWeight:2,
fillColor:"#0000FF",
fillOpacity:0
});
Circle.setMap(map);
}