Hello,
I’m interested in the feature of OSM where, if you search for a geographical entity, the found item will be nicely outlined with a polygon, and the zoom level of the map will be so that the polygon will fit into the viewport, no matter how big or small the entity is.
For example here’s what I mean concerning Uruguay: Relation: Uruguay (287072) | OpenStreetMap
In a web application I’m building at the moment—which contains a special experts database for connecting people doing research work about matters concerning the Spanish- and Portuguese-speaking world—, I’d like to have exactly this behavior. I already got some nice OSM-related things done, using Leaflet as the frontend Javascript library, however here I’m a bit stuck.
Our experts are able to choose geographical entities of various sizes from a controlled vocabulary—as we like to call it in humanities—as their areas of interest; for example, “Uruguay” as a whole country, or “Montevideo” as a city (in this case the capital of Uruguay), or “Treinta y Tres” as a department (in this case one of Uruguay’s). Each of these entities is associated with a latitude and longitude pair which, to my understanding, points to the geographical center of the respective entity.
Now, I figure that there is a way of getting the (possibly many) latitude-longitude pairs that are needed in order to achieve this, that is, to draw the polygon using Leaflet. Another map application, mapy.cz from the Czech Republic, apparently does it this way, inferring from how they build their URLs. I strongly believe that mapy.cz uses OSM under the hood.
Or is there another way to do it? Please give me a hint in which direction to carry on
With best regards from the Ibero-American world!