Gustavo Guerra
Gustavo Guerra

Reputation: 5359

Auto zooming the map control

When we display a Map control on Windows Phone 8, and we display a MapRoute, is there any way to auto set the zoom level so the full route first?

Upvotes: 0

Views: 1070

Answers (3)

Mathco Software
Mathco Software

Reputation: 41

To auto-zoom the map in c# with a list of coordinates (instead of a route), you can auto-generate a view by using the following:

//Adjust zoom
LocationRectangle lr = 
   LocationRectangle.CreateBoundingRectangle(myGeoCoordinate, incidentGeoCoordinate, [and more]);
myMap.SetView(lr);

Upvotes: 4

Jakub Krampl
Jakub Krampl

Reputation: 1794

If you have "Route" instead of "MapRoute", you can use "BoundingBox".

yourMapControl.SetView(route.BoundingBox)

Upvotes: 3

Matt Lacey
Matt Lacey

Reputation: 65564

There's no way to say "zoom to include points A,B & X,Y" but if you know these you could calculate the distance between them and the center point between those outlying points and then center on that point and then set a zoom level which will include the whole area.

Upvotes: 1

Related Questions