开发者

Bing maps, how to scale map?

How to scale map to show al开发者_如何转开发l pushpins in the map at one time? I use "Bing Maps AJAX Control, Version 7.0". Thank you!


There is a method called LocationRect that can be used for this. Here is an example from MSDN :

function init(){
// Load the map
var map = new Microsoft.Maps.Map(
    document.getElementById("myMap"),
    {
        credentials: "YOUR-BING-KEY",
        mapTypeId: Microsoft.Maps.MapTypeId.road
    }
);

// Some sample pins
var locs = [];
var loc1 = new Microsoft.Maps.Location(-10, 0);
var pin1 = new Microsoft.Maps.Pushpin(loc1 , {text: '1'});

var loc2 = new Microsoft.Maps.Location(0, 10);
var pin2 = new Microsoft.Maps.Pushpin(loc2, {text: '2'});

var loc3 = new Microsoft.Maps.Location(10, 0);
var pin3 = new Microsoft.Maps.Pushpin(loc3, {text: '3'});

var loc4 = new Microsoft.Maps.Location(20, -20);
var pin4 = new Microsoft.Maps.Pushpin(loc4, {text: '4'});

locs.push(loc1);
locs.push(loc2);
locs.push(loc3);
locs.push(loc4);

map.entities.push(pin1);
map.entities.push(pin2);
map.entities.push(pin3);
map.entities.push(pin4);
var bestview = Microsoft.Maps.LocationRect.fromLocations(locs);
map.setView({bounds:bestview });

}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜