In the documentation is says you can set the bounds of your map by using the fitBounds prop.
There is no prop on the MapGL. fitBounds does nothing.
There is also no bounds prop
How can I set the bounds of the map?
Below is the interface of the Mapbox to show there is no fitBounds.
export interface MapboxProps extends Partial<ViewState> {
container?: object;
gl?: object;
mapboxApiAccessToken?: string;
attributionControl?: boolean;
preserveDrawingBuffer?: boolean;
reuseMaps?: boolean;
transformRequest?: (url?: string, resourceType?: string) => MapRequest;
mapOptions?: object;
mapStyle?: string | object;
visible?: boolean;
onLoad?: (event: MapLoadEvent) => void;
onError?: (e: MapError) => void;
reuseMap?: boolean;
width: number | string;
height: number | string;
viewState?: ViewState;
}
http://uber.github.io/react-map-gl/#/Documentation/api-reference/static-map?section=faq
Hi @Pessimistress , I see you've pointed @mnoster to a static-map for bounds, but is there anyway to set bound on an interactive-map temporarily, (say for example, on the creation of a marker or a LineString), and then allow control again? Not sure if I should open another thread. Thank you!
Updated link to API docs: https://uber.github.io/react-map-gl/docs/api-reference/static-map#where-is-fitbounds
Updated link, again: https://visgl.github.io/react-map-gl/docs/api-reference/static-map#where-is-fitbounds
If someone finds this useful, here鈥檚 a complete example of using fitBounds in ReactMapGL to center points on map:
https://gist.github.com/tomsoderlund/a2040d659aafe4064e4060f561aca6d1
Most helpful comment
If someone finds this useful, here鈥檚 a complete example of using
fitBoundsin ReactMapGL to center points on map:https://gist.github.com/tomsoderlund/a2040d659aafe4064e4060f561aca6d1