Bing Mapx V8 pushpins locations to zoom out to show all pins

heyyy 96 Reputation points
2021-08-15T04:03:05.037+00:00

fromLocations, fromEdges, fromShapes, nothing works on map initialization. This is being loaded into a modal.

The first time I open the map, the zoom is arbitrary and sometimes the two pushpins are very close together. Subsequent map openings work properly and the zoom is set according to fromLocations.

Interestingly enough the fromLocations works properly with a single Location on map initialization, but not with two or more locations.

Let's fix this please. Thank you

//var rect = Microsoft.Maps.LocationRect.fromLocations(uniqueMSMapLocs.concat(homeLoc));
var rect = Microsoft.Maps.LocationRect.fromShapes(pushpins.concat(homepin));
MSmap.setView({
mapTypeId: Microsoft.Maps.MapTypeId.canvasLight,
//center: new Microsoft.Maps.Location(47.6205, -122.3493),
//zoom: 20
//center: new Microsoft.Maps.Location(userData.latitude, userData.longitude)
bounds: rect,
padding: 80
});

And can we also make some bing maps tags available for future questions please. Thanks

Windows Maps
Windows Maps
A Microsoft app that provides voice navigation and turn-by-turn driving, transit, and walking directions.
254 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. IoTGirl 2,976 Reputation points Microsoft Employee
    2021-08-16T20:53:40.413+00:00

    Hello Heyyy,

    Windows Maps is the correct tag to use or you can ask questions on Bing Maps at Answers.Microsoft.com > Bing > Maps. We do not have a tag for "Bing Maps" as there is confusion around Developer versus consumer questions so those should go to the Answers.com site.

    For this issue, is there a reason you are starting at zoom of 20? For multiple points, you probably want to start at a wider zoom size to ensure the points are viewable. Here are a few examples I can suggest:

    1. https://www.bing.com/api/maps/sdkrelease/mapcontrol/isdk/deletepushpins -> Adds multiple pushpins then deletes them
    2. https://www.bing.com/api/maps/sdkrelease/mapcontrol/isdk/addmultiplelayeritems -> Adds multiple items in a data layer (This is probably the best option without knowing more of your scenario)
    3. https://www.bing.com/api/maps/sdkrelease/mapcontrol/isdk/clusteringmeanaverage -> Clustering can be customized per layer/zoom level and is easier to use if you have alot of data points.

    I recommend taking a look at the different samples in the left menu of the iSDK to see which might best match your needs.

    Sincerely,
    IoTGirl

    0 comments No comments