I've found your library and so far it works really great, appreciate how well done and lightweight it is.
I'm trying to center map on a clicked point, which I track with signal, however it is not working for me. Could you please kindly suggest where to look for an issue?
import {
Layer,
Map,
Source,
useMap,
} from "solid-maplibre";
import layers from "protomaps-themes-base";
import { useNavigate } from "@solidjs/router";
import { createSignal, createEffect, onMount } from "solid-js";
export default function MaplibreMap() {
const navigate = useNavigate();
const [id, setId] = createSignal(null);
createEffect(() => {
console.log("Id is ", id());
useMap()?.()?.flyTo({
center: e.features[0].geometry.coordinates,
});
});
const navigateOnClick = (e) => {
setId(e.features[0].properties.uprn);
navigate(
"/property/" +
e.features[0].properties.address
.toLowerCase()
.replaceAll(",", "")
.split(" ")
.join("-"),
{ replace: true },
);
};
return (
<Map
class="map"
style={{
height: "100vh",
}}
options={{
center: [-1.2554869572956684, 51.75910108769326],
style: {
version: 8,
glyphs: ENV.GLYPH_URL
sources: {
uk: {
type: "vector",
url: ENV.TILES,
attribution:
'<a href="https://protomaps.com">Protomaps</a> © <a href="https://openstreetmap.org">OpenStreetMap</a>',
},
},
layers: layers("uk", "light"),
},
zoom: 7,
minZoom: 5,
maxZoom: 18,
}}
>
<Source
source={{
id: "ppd",
type: "vector",
url: ENV.PPD,
}}
>
<Layer
onclick={(e) => {
navigateOnClick(e);
}}
layer={{
id: "ppd_uk",
"source-layer": "ppd_data",
type: "circle",
paint: {
"circle-color": "#223b53",
"circle-radius": 6,
},
}}
/>
</Source>
</Map>
);
}