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

    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.


    DK

    Wednesday, July 03, 2013 1:07 AM

Answers

All replies

  • Look at LocationRect.fromLocations:

    http://msdn.microsoft.com/en-us/library/gg427621.aspx

    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 http://www.earthware.co.uk/blog | http://www.twitter.com/earthware | Windows Live Developer MVP

    Wednesday, July 03, 2013 10:33 AM
    Moderator
  • 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!

    DK

    Wednesday, July 03, 2013 5:44 PM