Question:
Can Google Maps v3 be restricted to display a specific area, with limited zoom levels?
Answer:
Yes, it is possible to achieve this using the following techniques:
Limiting Viewable Area:
Example:
<code class="javascript">var bounds = new google.maps.LatLngBounds( new google.maps.LatLng(lat1, lng1), new google.maps.LatLng(lat2, lng2) ); var mapOptions = { restrictions: { latLngBounds: bounds } }; var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);</code>
Limiting Zoom Level:
Example:
<code class="javascript">var mapOptions = { minZoom: 6, maxZoom: 9 }; var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);</code>
Note:
Restricting zoom level using StyledMap is limited to the ROADMAP base map type. Using the minZoom and maxZoom options provides a more comprehensive solution.
Additional Notes:
The above is the detailed content of Can Google Maps v3 Be Restricted to Display a Specific Area with Limited Zoom Levels?. For more information, please follow other related articles on the PHP Chinese website!