How to dynamically change the zoom level in Bing Maps Ajax Control 7.0 RRS feed

  • Question

  • Based on the user query, I'm fetching spatial data from the database and create and put pushpins on the map. I don't know how many pushpins I'll have to put on the map nor do I know how apart they are - it depends on the query. I want to show all the pins on the map no matter how scattered they are. And so, based on the number of pins and their locations, the zoom level has to change dynamically. How can I do that? I could not find anything in the ViewOptions object to accomplish that; or maybe, I'm missing something. Please help. Thanks in advance.


    Wednesday, July 3, 2013 1:07 AM


All replies

  • Look at LocationRect.fromLocations:

    add the location of all your points and provide the resulting LocationRect to the map objects setView method

    Brian @ Earthware - UK interactive mapping web developers | | Windows Live Developer MVP

    Wednesday, July 3, 2013 10:33 AM
  • Thanks for the reply, Brian! After struggling for some time I figured it out. The name of the class (LocationRect) is little confusing. I thought that I have to provide exactly four points/locations. But, it turned out that it works even with two points (in my array). Thank you, anyway!


    Wednesday, July 3, 2013 5:44 PM