问题
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