gpt4 book ai didi

google-maps - 谷歌地图 : Dynamically Movable and Resizable Circle Overlay Script for v3

转载 作者:行者123 更新时间:2023-12-04 23:03:21 32 4
gpt4 key购买 nike

好的,我刚刚找到了我正在寻找的完美脚本。

http://web3o.blogspot.com.br/2010/05/google-maps-dynamically-movable-and.html

您可以在 Google map 上添加带纬度/经度和半径的圆圈。
问题是这个脚本是 仅适用于 v2 api。

我也找到了这个
http://www.mapdevelopers.com/draw-circle-tool.php

但是没有可用的代码或源代码:(

有人知道像这样的脚本可以在 v3 上运行吗?

谢谢

最佳答案

该功能内置于 Google Maps API v3 Drawing Library
Example
您可以将其自定义为只允许圈子(或只允许一个圈子)。
Working example
代码片段:

function initialize() {
var mapOptions = {
center: new google.maps.LatLng(-34.397, 150.644),
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
};

var map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);

var drawingManager = new google.maps.drawing.DrawingManager({
drawingMode: google.maps.drawing.OverlayType.CIRCLE,
drawingControl: false,
drawingControlOptions: {
position: google.maps.ControlPosition.TOP_CENTER,
drawingModes: [
google.maps.drawing.OverlayType.CIRCLE
]
},
circleOptions: {
fillColor: '#ffff00',
fillOpacity: 1,
strokeWeight: 5,
clickable: false,
editable: true,
zIndex: 1
}
});
drawingManager.setMap(map);
google.maps.event.addListener(drawingManager, 'overlaycomplete', function(e) {
// Switch back to non-drawing mode after drawing a shape.
drawingManager.setDrawingMode(null);
});

}

google.maps.event.addDomListener(window, 'load', initialize);
html,
body {
height: 100%;
margin: 0;
padding: 0;
}
#map-canvas,
#map_canvas {
height: 100%;
}
@media print {
html,
body {
height: auto;
}
#map-canvas,
#map_canvas {
height: 650px;
}
}
#panel {
position: absolute;
top: 5px;
left: 50%;
margin-left: -180px;
z-index: 5;
background-color: #fff;
padding: 5px;
border: 1px solid #999;
}
<script src="https://maps.googleapis.com/maps/api/js?libraries=drawing&key=AIzaSyCkUOdZ5y7hMm0yrcCQoCvLwzdM6M8s5qk"></script>
<div id="map-canvas"></div>

关于google-maps - 谷歌地图 : Dynamically Movable and Resizable Circle Overlay Script for v3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17622189/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com