Reputation: 14930
Im using the Bing Maps control on my Windows Phone 7 app, I need to make sure the user doesnt go outside a pre-defined area, how can I achieve this?
Upvotes: 1
Views: 917
Reputation: 3532
You can add a handler that listens to the viewchangeend event, which fires after the map view changes (i.e. after every pan/zoom action) - http://msdn.microsoft.com/en-us/library/microsoft.maps.mapcontrol.map_events.aspx.
When the viewchangeend event fires, retrieve the bounds of the new map view via the BoundingRectangle property (or just get the centrepoint of the map using the Center property) - http://msdn.microsoft.com/en-us/library/microsoft.maps.mapcontrol.map_properties.aspx
Then, check whether the new map view lies within your pre-defined area. If it doesn't, set the map back to the previous view or adjust it so that it lies in range again using the SetView() method http://msdn.microsoft.com/en-us/library/microsoft.maps.mapcontrol.core.mapcore.setview.aspx.
Upvotes: 2
Reputation: 25631
you could use a static image of a map instead of a map control its self.
The Bing Maps RESTful API has a static imagery endpoint - http://msdn.microsoft.com/en-us/library/ff701721.aspx
Upvotes: 0