Hi ,
Awesome package 馃憤
I ran exmaple for geolocatecontrol , it worked fine but when I used geolocatecontrol with my project it is causing problem.
Current status
When I click on locate me , It moves map to my location and zooms too much that I can't see anything. Then I have to click zoomout button 17 times to get a proper view.
Expected
Should work same as shown in exmaple
code
<ReactMapGL
{...this.state.viewport}
width="100vw"
height="100vh"
mapStyle="mapbox://styles/mapbox/dark-v9"
onViewportChange={this._onViewportChange}
mapboxApiAccessToken={TOKEN}
>
{this.state.data.map(this._renderCityMarker)}
{this._renderPopup()}
<GeolocateControl
style={geolocateStyle}
positionOptions={{enableHighAccuracy: true}}
fitBoundsOptions ={{maxZoom: 4}}
trackUserLocation={true}
/>
<div style={fullscreenControlStyle}>
<FullscreenControl />
</div>
<div style={navStyle}>
<NavigationControl />
</div>
</ReactMapGL>
I tried to fix this by using fitBoundOptions but nothing changed.
Thanks,
any solution to this
@cngeru Not yet.... :(
@cngeru found it...
<GeolocateControl
onViewportChange={this._onViewportChange}
style={geolocateStyle}
positionOptions={{ enableHighAccuracy: true }}
trackUserLocation={true}
/>
Set zoom level after map moves as you want
_onViewportChange = (viewport) => {
viewport.zoom=3 //Whatever zoom level you want
this.setState({ viewport })
}
closing it
Can you auto geolocate user on component mounting ?
Most helpful comment
@cngeru found it...
Set zoom level after map moves as you want