-1

Im trying to change the mapview while using Bing maps API. I have my map initialized already but im trying to change the map view to center in on a pin who's location i have. Im merely trying to get the view to move using setView but im unsure how to move it.

function findpin() {
    console.log("hello3");
    var pin;
    //loop through and find searched pin object
    for (var i = 0; i < allPins.length; i++) {
        if (searchbox.value == allPins[i].entity.title) {
            pin = allPins[i];
            break;
        }
    };
    console.log(pin);
    //set pin
    pinSelected(pin);
    //var locs = [array of Microsoft.Maps.Location];
    //var rect = Microsoft.Maps.LocationRect.fromLocations(locs);
    map = setView({
       mapTypeId: Microsoft.Maps.MapTypeId.aerial,
       center:new Microsoft.Maps.Location(0, 0),
       zoom:100,
    });
    console.log("hello5");
}
J.Rom
  • 1

1 Answers1

0

Assuming that you initialized the map by:

var map = new Microsoft.Maps.Map(document.getElementById('myMap'), {});

Then you can use the setView on the instantiated map to update the view:

map.setView({ 
    mapTypeId: Microsoft.Maps.MapTypeId.aerial,
    center: new Microsoft.Maps.Location(0, 0),
    zoom: 20
});

Notice that the max zoom level is 20.

J S
  • 1,068
  • 6
  • 7