Joel
Joel

Reputation: 324

Bing Map V8 control error changing map type from streetside to road

I'm using the Bing Map V8 control. I can change my map type from road to streetside but not from streetside to road or aerial. Why does this fail?

I need to use a separate input button to change the map type on my application based on some business logic and have always switched between aerial and road this way.

If you paste the following javaScript into the javascript panel of the interactive examples site I think you will see what is happening, https://www.bing.com/api/maps/sdkrelease/mapcontrol/isdk#streetsideFailoverToRoad+JS. Unfortunately, I couldn't get the Bing Map to display in a snippet / example embedded here.

It is suppose to change the map type after waiting two seconds but only works in one direction road to streetside.

This code fails if I start in a map type of streetside and try to change to road.

var map = new Microsoft.Maps.Map(document.getElementById('myMap'), {
    credentials: 'Your Bing Maps Key',
    mapTypeId: Microsoft.Maps.MapTypeId.streetside,
    center: new Microsoft.Maps.Location(47.608, -122.335),
    streetsideOptions: {showExitButton: false }
});

setTimeout(changeToRoad, 2000 /*ms*/);

function changeToRoad(){
    map.setView({ mapTypeId: Microsoft.Maps.MapTypeId.road }); // this line fails
}

This code works, the only difference is that it starts with a map type of road and changes to streetside.

var map = new Microsoft.Maps.Map(document.getElementById('myMap'), {
    credentials: 'Your Bing Maps Key',
    mapTypeId: Microsoft.Maps.MapTypeId.road,
    center: new Microsoft.Maps.Location(47.608, -122.335),
    streetsideOptions: {showExitButton: false }
});

setTimeout(changeToRoad, 2000 /*ms*/);

function changeToRoad(){
    map.setView({ mapTypeId: Microsoft.Maps.MapTypeId.streetside }); // this line works
}

Upvotes: 0

Views: 533

Answers (1)

rbrundritt
rbrundritt

Reputation: 17964

Have you tried the experimental branch (add &branch=experimental to the map script URL). This issue looks to already be fixed there. The fixes in the experimental branch will be rolled into the main release branch in about a week and a half. 

Upvotes: 1

Related Questions