Reputation: 33
Is there any way to forbid the option about moving around the map?
var map = new google.maps.Map(document.getElementById('map-canvas'), {
center:{
lat: lat,
lng: lng
},
zoom: 15
});
I want my map to be positioned on the latitude and longitude, and the zoom to be specific, and the map to stay static (just like a picture), so you cannot see anything else than what is there in the map provided.
Upvotes: 0
Views: 69
Reputation: 161334
Disable dragging, zooming, the default UI, etc..
var map = new google.maps.Map(document.getElementById('map-canvas'), {
center: {
lat: 42,
lng: -72
},
zoom: 15,
draggable: false,
zoomControl: false,
streetViewControl: false,
mapTypeControl: false,
disableDoubleClickZoom: true,
scrollwheel: false,
disableDefaultUI: true
});
code snippet:
function initialize() {
var map = new google.maps.Map(document.getElementById('map-canvas'), {
center: {
lat: 42,
lng: -72
},
zoom: 15,
draggable: false,
zoomControl: false,
streetViewControl: false,
mapTypeControl: false,
disableDoubleClickZoom: true,
scrollwheel: false,
disableDefaultUI: true
});
}
google.maps.event.addDomListener(window, "load", initialize);
html,
body,
#map-canvas {
height: 100%;
width: 100%;
margin: 0px;
padding: 0px
}
<script src="https://maps.googleapis.com/maps/api/js"></script>
<div id="map-canvas"></div>
Upvotes: 0