gpt4 book ai didi

javascript - 如何删除绘图层菜单选项?

转载 作者:行者123 更新时间:2023-12-03 06:41:58 27 4
gpt4 key购买 nike

如何删除绘图层菜单选项?

我正在使用下面的脚本,但我想删除下图中突出显示的选项。

<script type="text/javascript"
src="http://maps.google.com/maps/api/js?v=3.21&sensor=false&libraries=drawing"></script>

我只想要这些,但 map 显示不止三个。

var RECTANGLE = google.maps.drawing.OverlayType.RECTANGLE;
var CIRCLE = google.maps.drawing.OverlayType.CIRCLE;
var POLYGON = google.maps.drawing.OverlayType.POLYGON;

remove highlighted option

enter image description here

最佳答案

您无法(轻松)移开手(如果您想这样做,则需要制作自己的自定义控件)。

要仅显示您想要的三个,再加上手,请在 API 控件中仅在drawingControlOptions的绘图模式属性中包含您想要的那些。对于 map :

代码片段:(基于 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);
}
html,
body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 100%;
}
<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&key=AIzaSyCkUOdZ5y7hMm0yrcCQoCvLwzdM6M8s5qk" async defer></script>

关于javascript - 如何删除绘图层菜单选项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37913757/

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