如何删除绘图层我使用下面的脚本,但我想删除下面突出显示的选项,请帮助我。
<script type="text/javascript"
src="http://maps.google.com/maps/api/js?v=3.21&sensor=false&libraries=drawing"></script>
我想要这些oly但是地图显示超过三个
var RECTANGLE = google.maps.drawing.OverlayType.RECTANGLE;
var CIRCLE = google.maps.drawing.OverlayType.CIRCLE;
var POLYGON = google.maps.drawing.OverlayType.POLYGON;
答案 0 :(得分:1)
你不能(轻松)移开手(如果你想这样做,你需要自己制作自定义控件)。
要仅在API控件中显示所需的三个,再加上手,只在地图的drawingControlOptions的drawingModes属性中包含您想要的那些:
代码段:(基于example in the documentation)
// This example requires the Drawing library. Include the libraries=drawing // parameter when you first load the API. For example:
// <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=drawing">
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
center: {
lat: -34.397,
lng: 150.644
},
zoom: 8
});
var drawingManager = new google.maps.drawing.DrawingManager({
drawingMode: google.maps.drawing.OverlayType.MARKER,
drawingControl: true,
drawingControlOptions: {
position: google.maps.ControlPosition.TOP_CENTER,
drawingModes: [google.maps.drawing.OverlayType.CIRCLE, google.maps.drawing.OverlayType.POLYGON, google.maps.drawing.OverlayType.RECTANGLE]
},
markerOptions: {
icon: 'https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png'
},
circleOptions: {
fillColor: '#ffff00',
fillOpacity: 1,
strokeWeight: 5,
clickable: false,
editable: true,
zIndex: 1
}
});
drawingManager.setMap(map);
}
&#13;
html,
body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 100%;
}
&#13;
<div id="map"></div>
<!-- Replace the value of the key parameter with your own API key. -->
<script src="https://maps.googleapis.com/maps/api/js?libraries=drawing&callback=initMap" async defer></script>
&#13;