MapTiler setup
How to render MapTiler Cloud styles on the Web through MapConductor. It renders with maplibre-gl, and the style resolves to a MapTiler Cloud URL carrying your API key.
Before you start
Install
Install the core, the React bindings and the provider package. Swapping providers changes only that third one.
npm install @mapconductor/js-sdk-core @mapconductor/js-sdk-react \
@mapconductor/react-for-maptilerExclude it from Vite pre-bundling
Under Vite, add the provider to optimizeDeps.exclude. maplibre-gl v6 loads its worker by URL, and pre-bundling does not emit that worker file into .vite/deps, so the request fails.
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
export default defineConfig({
optimizeDeps: {
exclude: ["@mapconductor/react-for-maptiler", "@mapconductor/js-sdk-core"],
},
plugins: [react()],
});Import the stylesheet
Import it once from your application entry point. Forget it and the map's layout and controls come out wrong.
import '@mapconductor/react-for-maptiler/style.css';
Pass the API key to the state hook
The key is woven into the style JSON URL: https://api.maptiler.com/maps/<style>/style.json?key=…
const state = useMapTilerViewState({
apiKey: import.meta.env.VITE_MAPTILER,
mapDesignType: MapTilerDesign.Streets,
cameraPosition: createMapCameraPosition({ position: TOKYO, zoom: 12 }),
});VERIFY
What you should see
The setup is complete when the map renders in a MapTiler style.
import { useState } from 'react';
import { createGeoPoint, createMapCameraPosition, createMarkerState } from '@mapconductor/js-sdk-core';
import { Marker } from '@mapconductor/js-sdk-react';
import { MapTilerDesign, MapTilerMapView2D, useMapTilerViewState } from '@mapconductor/react-for-maptiler';
import '@mapconductor/react-for-maptiler/style.css';
const TOKYO = createGeoPoint({ latitude: 35.6812, longitude: 139.7671 });
export function MapTilerMap() {
const state = useMapTilerViewState({
apiKey: import.meta.env.VITE_MAPTILER,
mapDesignType: MapTilerDesign.Streets,
cameraPosition: createMapCameraPosition({ position: TOKYO, zoom: 12 }),
});
const [markerState] = useState(() => createMarkerState({ id: 'tokyo', position: TOKYO }));
return (
<MapTilerMapView2D state={state} style={{ height: 480 }}>
<Marker state={markerState} />
</MapTilerMapView2D>
);
}Map designs
MapTilerDesign covers the MapTiler Cloud reference styles.
Troubleshooting
The map stays blank
- Check apiKey is not an empty string — a missing environment variable is the usual cause.
- Confirm the key is active in MapTiler Cloud and you are within your quota.
The map's layout or controls look broken
- Check you imported style.css.
The map initialises twice in development
- React StrictMode double-invokes effects. Every provider detects this and discards the aborted run, so you do not need to turn StrictMode off.
Next
It uses the same renderer as MapLibre, so its behaviour and constraints match that provider.