我一直试图限制地图的缩小范围。遇到属性restriction
,但是它不起作用。
编辑:
latLngBounds
对象在这里拥有全部的纬度。
我的参考资料是这样的: https://developers.google.com/maps/documentation/javascript/examples/control-bounds-restriction
代码:
<Map id="map"
mapTypeControl={false}
gestureHandling= {'greedy'}
zoomControl= {false}
streetViewControl={false}
fullscreenControl={false}
restriction= {{
latLngBounds: {north: 42.711540, south: 0.953572, west: 25.993644, east: 27.250767},
strictBounds: true,
}}
google={this.props.google}
zoom={7}
style={mapStyles}
styles= {[
{elementType: 'geometry.fill', stylers: [{color: '#F2F2F2'}]},
{
featureType: 'water',
elementType: 'geometry',
stylers: [{color: '#E3E3E3'}]
},
{
featureType: 'transit.line',
elementType: 'geometry',
stylers: [{visibility: 'off'}]
},
{
featureType: 'road',
elementType: 'labels',
stylers: [{visibility: 'off'}]
},
{
featureType: 'road',
elementType: 'geometry',
stylers: [{visibility: 'off'}]
},
{
featureType: 'water',
elementType: 'labels.text.fill',
stylers: [{color: '#515c6d'}]
},
{
featureType: 'water',
elementType: 'labels.text.stroke',
stylers: [{color: '#17263c'}]
}
]}
initialCenter={{
lat: 21.5937,
lng: 78.9629
}}
>