Reputation: 1
I have this symbol on a map
map.addLayer({
"id": "home",
"type": "symbol",
"source": "property",
"interactive": true,
"layout": {
"icon-image": "rocket-15",
}
});
I would like to zoom in to this marker and center on it.
So far I have tried this:
map.featuresIn({ layer: 'home' }, function(err, features) {
console.log(features);
map.flyTo({ center: features[0].geometry.coordinates,zoom: 11 });
});
I omit the coordinates argument, so I refer to it directly (as stated in API). However, the 'features' arrive empty and I can never fly
Upvotes: 0
Views: 2730
Reputation: 3802
featuresIn
does not return features' geometries by default. For that, you must include the includeGeometry: true
parameter.
You will find this example helpful!
Upvotes: 1