I want to zoom to some co-ordinates on page load; Below is my code.
Currently I can’t understand how to zoom the map to a point (let’s say:-33.860000, 151.209389). If I set CurrentExtent to an arbitrary RectangleShape as in line # 37, it does not work and raises an exception; while line # 38 works. But I need to show the Point zoomed-in.
How to do this? Also, is there any documentation available for iOS on your site?
01.
class MapViewController2 : UIViewController
02.
{
03.
private MapView iOSMap;
04.
public override void ViewDidLoad()
05.
{
06.
base.ViewDidLoad();
07.
08.
// Set the main view frame
09.
View.Frame = UIScreen.MainScreen.Bounds;
10.
View.BackgroundColor = UIColor.White;
11.
View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
12.
13.
// Create MapView
14.
iOSMap = new MapView(View.Frame);
15.
iOSMap.MapUnit = GeographyUnit.Meter;
16.
iOSMap.BackgroundColor = new UIColor(233, 229, 220, 200);
17.
iOSMap.ZoomLevelSet = new BingMapsZoomLevelSet();
18.
19.
// Add ThinkGeo Location Marker.
20.
Marker thinkGeoLocation = new Marker();
21.
thinkGeoLocation.Position = new PointShape(-28.5537, 153.5084);
22.
thinkGeoLocation.SetImage(UIImage.FromBundle(“Pin”), UIControlState.Normal);
23.
MarkerOverlay markerOverlay = new MarkerOverlay();
24.
markerOverlay.Markers.Add(thinkGeoLocation);
25.
iOSMap.Overlays.Add(“markerOverlay”, markerOverlay);
26.
27.
BingMapsTileOverlay bingMapOverlay = new BingMapsTileOverlay(“bing key”);
28.
iOSMap.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
29.
iOSMap.Overlays.Add(bingMapOverlay);
30.
31.
string rootPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
32.
bingMapOverlay.MapType = BingMapsMapType.AerialWithLabels;
33.
bingMapOverlay.TileCache = new FileBitmapTileCache(rootPath + “/CacheImages”, “Road”);
34.
bingMapOverlay.TileCache.TileMatrix.BoundingBoxUnit = GeographyUnit.Meter;
35.
bingMapOverlay.TileCache.TileMatrix.BoundingBox = bingMapOverlay.GetBoundingBox();
36.
bingMapOverlay.TileCache.ImageFormat = TileImageFormat.Jpeg;
37.
//iOSMap.CurrentExtent = new RectangleShape (-32.860000, 151.219389, -33.860000, 151.209389);//this raises an error
38.
iOSMap.CurrentExtent = bingMapOverlay.GetBoundingBox();//this displays map okay; but I need to zoom the map to -33.860000, 151.209389
39.
iOSMap.ZoomTo(iOSMap.CurrentExtent);
40.
// Add MapView to MainView
41.
View.AddSubview(iOSMap);
42.
iOSMap.Refresh();
43.
}
44.
}