我想在我的谷歌地图的右下角显示放大(+)和缩小选项( - )。我尝试了这个,但我没有得到缩放选项。
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDQ2&callback=initMap">
</script>
<script type="text/javascript">
window.onload = function () {
var mapOptions = {
center: new google.maps.LatLng(17.44633567526379, 78.38290556613924),
zoom: 14,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var infoWindow = new google.maps.InfoWindow();
var latlngbounds = new google.maps.LatLngBounds();
var map = new google.maps.Map(document.getElementById("dvMap"), mapOptions);
google.maps.event.addListener(map, 'click', function (e) {
alert("Latitude: " + e.latLng.lat() + "\r\nLongitude: " + e.latLng.lng());
document.getElementById("txtLongitude").value = e.latLng.lng();
document.getElementById("txtLatitude").value = e.latLng.lat();
});
}
</script>
<div id="dvMap" style="width: 700px; height: 300px">
</div>
答案 0 :(得分:0)
在MapOptions中添加zoomControl: true
,如下所示:
var mapOptions = {
center: new google.maps.LatLng(17.44633567526379, 78.38290556613924),
zoomControl: true,
zoom: 14,
mapTypeId: google.maps.MapTypeId.ROADMAP
};