在Google Maps API v3中绘制几个圆圈

时间:2013-09-23 19:24:47

标签: google-maps google-maps-api-3

我想在Google Maps API v3中绘制几个圆圈。我找到了一个似乎正确的脚本。但到目前为止,它仅适用于一个圆圈。这段代码应该如何绘制“birrfeld”和“zuerich”?

<script>
var birrfeld=new google.maps.LatLng(47.443411,8.234478);
var aelggialp=new google.maps.LatLng(46.80121,8.226692);
var zuerich=new google.maps.LatLng(47.463031,8.549252);

function initialize()
{
var mapProp = {
center:aelggialp,
zoom:8,
mapTypeId:google.maps.MapTypeId.ROADMAP
};

var map = new google.maps.Map(document.getElementById("googleMap"),mapProp);

var myCity = new google.maps.Circle({
center:birrfeld,
radius:6000,
strokeColor:"#0000FF",
strokeOpacity:0.8,
strokeWeight:2,
fillColor:"#0000FF",
fillOpacity:0.4
});
var zuerich = new google.maps.Circle({
center:zuerich,
radius:8000,
strokeColor:"#0000FF",
strokeOpacity:0.8,
strokeWeight:2,
fillColor:"#0000FF",
fillOpacity:0.4
});

myCity.setMap(map);
}

google.maps.event.addDomListener(window, 'load', initialize);
</script>

1 个答案:

答案 0 :(得分:1)

你不是在打电话:

zuerich.setMap(map);

示例:http://jsfiddle.net/jKuck/