infusion-code / angular-maps

Angular Maps (X-Map) is a set of components and services to provide map functionality in angular 2+ apps. X-Maps architecture is provider independent and can be used with Bing, Google, ESRI or any other service enabled mapping provider. X-Map contains a default implementation for Bing Maps.
MIT License
41 stars 34 forks source link

Set IBox around result #112

Open ElesGergo opened 4 years ago

ElesGergo commented 4 years ago

Hello, I was checking at the examples and the documentation but I do not found anything related to IBox. How can I set the the map to be zoomed around the results? Is there a way to calculate it ?

thor-schueler commented 4 years ago

Check out this example: https://stackblitz.com/edit/bing-map-with-spider-clusters

Notice in the app.Component.ts there is a member _box of IBox type. It is bound to the "Box" property of the Map in app.compoennt.html. In this example it is set statically, but it is trivial to do this with dynamic ranges:

Hope that helps.

ElesGergo commented 4 years ago

Thanks for the reply, @thor-schueler maybe my question was not explained well in detail, I want to set the boundaries for a single lat-lng pair. For example I have a city with the longitude latituede of it. Lets say: Jena, Thuringia, Germany (50.927223, 11.586111) How can I set the box property since I dont know the min-max values? Is there some way to calculate them? My ide was to set the center for the box porperty and add some margin, but since the min-max values are requred that does not seem to work.

thor-schueler commented 4 years ago

Jena, eh? I grew up around the corner from there lol. In Erfurt. Do you live there?

Anyway, as to your question (oder zur Frage, perhaps more appropriately): The way I have dealt with this in the past is to use the coordinate as the center of the map as you suggest and use the zoom instead of a box (the map will then calculate the box automatically based on the zoom).

<x-map #xmap [Latitude]="50.927223" [Longitude]="11.586111" Zoom="12" [Options]="_options">

Working sample is at https://stackblitz.com/edit/bing-map-with-geo-center-and-scale

ElesGergo commented 4 years ago

Vielen Dank, for the solution. I ended up with it for now, however it would be great to find some alternave since it is hard to make it work with for example cities of different size. I was looking for an api to help me out at least with the major cities (using Bing rest and bing maps), however the bbox result are really not accurate.

thor-schueler commented 4 years ago

So essentially, you are looking for a way to auto-determine either zoom or figure out a box depending on a geographic feature (like the size of a city). Yeah, the maps package here deals mostly with rendering and managing the map, not so much with those type of calculations and activities. One way to go about that perhaps would be to calculate expected size of a city as a derivative of population. You could:

ElesGergo commented 4 years ago

Thank you very much! The third option is what I was thinking about.