I want to simply center my map on the search result of a polygon using leaflet. I thought to return the bounding box, as this is closer to what I actually need.
I want to use flyTo()
I see a possible way to do this by using Leaflet?
I have a thought to do this
SELECT ST_AsGeoJSON (geom) AS geom, Box2D(geom) as bounds, ST_YMax(Box2D(geom)) as ymax, ST_YMin(Box2D(geom)) as ymin, ST_XMax(Box2D(geom)) as xmax, ST_XMin(Box2D(geom)) as xmin FROM nation_shapes WHERE (condition)
and then pass it to
mymap.flyToBounds([[ymax, xmax],[ymin, xmin]])
Though this seems inefficient. I would like to be able to get this information from the object I am already passing back if possible, or convert something like Box2D(geom) as bounds
which would be more efficient than calling it 4 times, I think.
flyTo
method takes as argument single lat,lng point,flyToBounds
method takes bounding box as argument.