0

你好 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 个标记:

纬度 29.937641 长 -93.969326 纬度 30.063964 长 -94.116131

我如何将其合并到上面的代码中?或者反之亦然,如果我有带点的代码,我将如何合并圆形元素?

一如既往地提前感谢您的帮助!

4

1 回答 1

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);
}
于 2013-08-16T13:47:04.520 回答