-
Notifications
You must be signed in to change notification settings - Fork 349
Comparison with Xamarin.Forms.Maps
Explain about comparison with Xamarin.Form.Maps. Unless otherwise noted, these are supported for Android and iOS onkly.
-
Adds
-
Changes
-
Deletions
- None
Can drawing Polyline, Polygon and Circle by common API.
For example, you can add a polyline as follows.
// map as Xamarin.Forms.GoogleMaps.Map
var polyline = new Polyline();
polyline.Positions.Add(new Position(40.77d, -73.93d));
polyline.Positions.Add(new Position(40.81d, -73.91d));
polyline.Positions.Add(new Position(40.83d, -73.87d));
polyline.StrokeColor = Color.Blue;
polyline.StrokeWidth = 5f;
polyline.Tag = "POLYLINE"; // Can set any object
polyline.IsClickable = true;
polyline.Clicked += (s, e) =>
{
// handle click polyline
};
map.Polylines.Add(polyline);
You can delete a polyline as follows.
map.Polylines.Remove(polyline);
In polyline or polygon, if you set IsClickable
to true
then you can subscribe Clicked
events.
Circle have not IsClickable
property and Clicked
events. Because Android native Google Maps API does not support circle clicking.
For more information, refer to ShapesPage.xaml.cs
in SampleApp - XFGoogleMapSample.
- In v1.1.0,
Pin
,Polyline
,Polygon
andCircle
's each properties does not support binding.
You can set pin to Map.SelectedPin
, then show info-window and pin marks "selected".
Set null
to Map.SelectedPin
, then close info-window and pin marks "unselected".
For more information, refer to PinsPage.xaml.cs
in SampleApp - XFGoogleMapSample.
Raise Map.SelectedPinChanged
event when pin selected.
This event occur when tap pin yourself or set Map.SelectedPin
property.
If unselected, SelectedPinChangedEventArgs.SelectedPin
to be null
.
map.SelectedPinChanged += (object sender, SelectedPinChangedEventArgs e) =>
{
labelStatus.Text = $"SelectedPin changed - {e?.SelectedPin?.Label ?? "nothing"}";
}
You can customize marker icon.
For example, you can use platform bundle images as marker, as follows.
pin.Icon = BitmapDescriptorFactory.FromBundle("image01.png");
You should prepare image01.png
in Android-"Android Asset" or iOS-"BundleResource".
In others, you can use BitmapDescriptorFactory.FromStream
and BitmapDescriptorFactory.DefaultMarker
.
For more information, refer to CustomPinsPage.xaml.cs
in SampleApp - XFGoogleMapSample.
Custom pin icon in iOS bigger than Android. If you have any comments, please post here - issue #40 .
Add TileLayer
object to Map.TileLayers
, you can display original map tiles.
For example, you can display the GSI Maps as follows.
var tileLayer = TileLayer.FromTileUri((int x, int y, int zoom) =>
new Uri($"https://cyberjapandata.gsi.go.jp/xyz/std/{zoom}/{x}/{y}.png")
);
map.TileLayers.Add(tileLayer);
If you want return image directory, you can use TileLayer.FromSyncImage
or TileLayer.FromAsyncImage
.
For more information, refer to TilesPage.xaml.cs
in SampleApp - XFGoogleMapSample.
Set animate
parameter to true
, then animation when map panning. set to false
, then panning directly. This is optional parameter, default is true
.
- (-v1.3.0)