MapConductor React SDK Samples

Fit Bounds | MapLibre | MapConductor React SDK

MapConductor React SDK Fit Bounds sample using MapLibre.

This interactive example demonstrates the Fit Bounds feature through the MapConductor abstraction on MapLibre.

Code example

import { createGeoPoint, createMapCameraPosition } from '@mapconductor/js-sdk-core';
import { MapLibreDesign, MapLibreMapView2D, useMapLibreViewState } from '@mapconductor/react-for-maplibre';


// (1) Create the map


const initialCamera = createMapCameraPosition({
  position: createGeoPoint({ latitude: 35.6812, longitude: 139.7671 }),
  zoom: 12,
});


const mapViewState = useMapLibreViewState({
  mapDesignType: MapLibreDesign.OsmBrightJa,
  cameraPosition: initialCamera,
});


// (2) Render the map and its overlays


<MapLibreMapView2D state={mapViewState}>
  {/* MapConductor overlays */}
</MapLibreMapView2D>

How the code works

Render provider-independent overlays inside the shared MapConductor map view.