I have a GeoJSON object “feature” stringified as :
{
"type": "Feature",
"properties": {
"id": 1039215298,
"version": 1,
"reference": "SRO-BPI-12121212",
"adresse": "235 RUE DU MAUBON",
"codePostal": "60750",
"ville": "CHOISY AU BAC",
"nbrLogements": 2,
"nbrLogementsDeployes": 2,
"tauxLogementsDeployes": 100
},
"geometry": {
"type": "Point",
"coordinates": [
2.87,
49.44
]
}
}
It should point to France.
I want to display the openstreetmap tiles, add a marker using GeoJSON layer and zoom in using the following leaflet commands:
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19, attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(map);
L.geoJSON(feature).addTo(map);
map.flyTo(feature.geometry.coordinates, 13);
The zoom doesn’t work: leaflet zoom to (49.44, 2.87) in Indian Ocean. I have to use the following code to correctly zoom in France:
map.flyTo(new L.LatLng(feature.geometry.coordinates[1],feature.geometry.coordinates[0]), 13)
Which is inconsistent. Can you please explain me why the coordinates are correctly displayed with GeoJSON layer but not correctly used by map.flyTo ? Is there a flyTo method for GeoJSON feature?