Is there a way to programmatically determine the optimal Bing Maps Zoom Level based on an array of GPS Coordinates?

≡放荡痞女 提交于 2021-01-07 02:40:21

问题


When programmatically adding an array of GPS Coordinates to a Bing Map, I want to set the Zoom level to the optimal - to show every pushpin/location, but "just barely."

I imagine a way to do this would be to identify the furthest points in the cardinal directions found within the array of coordinates, and then calculate how many miles you need to display both east-to-west and north-to-south.

For example, let's say the furthest north and furthest south locations are determined to be forty miles distant from each other, and the furthest east and furthest west locations are determined to be sixty miles apart from each other. Is there a rule of thumb/calculation/algorithm that would determine what the most "zoomed-in" level would be that would display all of the locations/coordinates, with the "outliers" being as close to the edge of the displayed portion of the map as possible?


回答1:


You can set a map view with a bounding box, which will automatically determine the zoom level. See the example here https://www.bing.com/api/maps/sdkrelease/mapcontrol/isdk/setmapviewoptions using the Bounds property as documented here https://docs.microsoft.com/en-us/bingmaps/v8-web-control/map-control-api/viewoptions-object



来源:https://stackoverflow.com/questions/65128312/is-there-a-way-to-programmatically-determine-the-optimal-bing-maps-zoom-level-ba

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!