Handy extensions to the Google Maps Android API.
Xamarin Android Binding Library for Google Maps Android API Utility Library
PM> Install-Package SushiHangover.Android.Maps.Utils
Ref: https://www.nuget.org/packages/SushiHangover.Android.Maps.Utils
I did not port the Java sample in the Google Repo to C#, would love a pull-request ;-)
I am using a number of the classes/methods in a few of projects so I know the "basics" work... If there are any methods that are returning Java.Lang.Object
vs. a more formal concrete class, post an issue or even better, a pull-reuquest ;-)
var kmlLayer = new KmlLayer(googleMap, Resource.Raw.campus, ApplicationContext);
kmlLayer.AddLayerToMap();
MoveCameraToKml(kmlLayer);
void MoveCameraToKml(KmlLayer kmlLayer)
{
//Retrieve the first container in the KML layer
var container = (KmlContainer)kmlLayer.Containers.Iterator().Next();
//Retrieve a nested container within the first container
container = (KmlContainer)container.Containers.Iterator().Next();
//Retrieve the first placemark in the nested container
var placemark = (KmlPlacemark)container.Placemarks.Iterator().Next();
//Retrieve a polygon object in a placemark
var polygon = (KmlPolygon)placemark.Geometry;
//Create LatLngBounds of the outer coordinates of the polygon
LatLngBounds.Builder builder = new LatLngBounds.Builder();
foreach (LatLng latLng in polygon.OuterBoundaryCoordinates)
{
builder.Include(latLng);
}
googleMap.MoveCamera(CameraUpdateFactory.NewLatLngBounds(
builder.Build(), mapFragment.View.Width, mapFragment.View.Height, 1)
);
}
Post issues on GitHub
Post on StackOverflow with the tags: [xamarin]
[xamarin.android]
[google-maps]
Library: https://github.com/googlemaps/android-maps-utils
Binding: https://github.com/sushihangover/SushiHangover.Android.Maps.Utils