I am trying to display Bing map using ThinkGeo Android Suite. But I am getting this error:
System.ArgumentOutOfRangeException: The input double value is out of range.
Parameter name: screenWidth
Here is the code:
01.
public class ThinkGeoActivity : Activity
02.
{
03.
private MapView androidMap;
04.
protected override void OnCreate(Bundle bundle)
05.
{
06.
PclShareEnvironment.Current = new AndroidEditionPclShareEnviroment();
07.
08.
base.OnCreate(bundle);
09.
SetContentView(Resource.Layout.DisplayASimpleMap);
10.
androidMap = FindViewById<
MapView
>(Agtrix.Droid.Resource.Id.androidmap);
11.
12.
PointShape thinkGeoCoordinate = new PointShape(153.5084, -28.5537);
13.
RectangleShape defaultExtent = new RectangleShape(151.209389, -33.430000, 151.219389, -34.29000);
14.
15.
ManagedProj4Projection wgs84ToBingProjection = new ManagedProj4Projection();
16.
wgs84ToBingProjection.InternalProjectionParametersString = ManagedProj4Projection.GetWgs84ParametersString();
17.
wgs84ToBingProjection.ExternalProjectionParametersString = ManagedProj4Projection.GetBingMapParametersString();
18.
wgs84ToBingProjection.Open();
19.
thinkGeoCoordinate = (PointShape)wgs84ToBingProjection.ConvertToExternalProjection(thinkGeoCoordinate);
20.
defaultExtent = wgs84ToBingProjection.ConvertToExternalProjection(defaultExtent);
21.
wgs84ToBingProjection.Close();
22.
23.
Marker thinkGeoLocation = new Marker(this);
24.
thinkGeoLocation.Position = thinkGeoCoordinate;
25.
thinkGeoLocation.OffsetX = -22;
26.
thinkGeoLocation.SetImageResource(Resource.Drawable.Point);
27.
MarkerOverlay markerOverlay = new MarkerOverlay();
28.
markerOverlay.Markers.Add(thinkGeoLocation);
29.
androidMap.Overlays.Add("markerOverlay", markerOverlay);
30.
31.
BingMapsTileOverlay bingMapOverlay = new BingMapsTileOverlay("Bing Key Here");
32.
androidMap.Overlays.Add(bingMapOverlay);
33.
34.
35.
bingMapOverlay.MapType = BingMapsMapType.AerialWithLabels;
36.
androidMap.CurrentExtent = defaultExtent;
37.
androidMap.Refresh();
38.
androidMap.ZoomTo(thinkGeoCoordinate.Buffer(500, GeographyUnit.Meter, DistanceUnit.Meter).GetBoundingBox());
39.
40.
41.
}
42.
43.
44.
45.
46.
}
Can you correct any issues with the above code? Or send me a sample solution. Note that the similar code was successfully used on iOS.