Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bing Maps API -- setBounds

I'm converting a mapping utility from Gmap to Bing. In Google Maps, you can easily add markers to the map, and each time you add a marker, you add the location of the marker to a bounds object, then call setBounds() on the map to recenter the map to fit all markers.

I cannot find a similar method to work with Bing Maps, and the docs are pretty lousy compared to Google's.

So far I've got the map created and markers added-- but the map stays stuck at the initial view, rather than updating to fit the markers.

Is there an equivalent of the setBounds method for the Bing javascript API, or is there another way to handle this?

like image 745
julio Avatar asked Jun 03 '26 15:06

julio


1 Answers

The way to do this in Bing is:

1) Use the LocationRect.fromLocations function (http://msdn.microsoft.com/en-us/library/gg427621.aspx) to create a bounding box from your pushpins locations 2) pass the LocationRect created in one to the map objects setViewFunction as part of the ViewOptions parameter http://msdn.microsoft.com/en-us/library/gg427628.aspx

like image 138
7 revs Avatar answered Jun 06 '26 07:06

7 revs



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!