private void ImageryLayer_RequestTileUri(object sender, Syncfusion.SfMaps.XForms.TileUriArgs e)
{
var link = "http://mt1.google.com/vt/lyrs=m&x=" + e.X.ToString() + "&y=" + e.Y.ToString() + "&z=" + e.ZoomLevel.ToString();
e.Uri = link;
} |
…
private void AddMarkersButton_OnClicked(object sender, EventArgs e)
{
this.AddMarker();
}
…
private void AddMarker()
{
this.imageryLayer.Markers.Add(new CustomMarker { Latitude = "22.787998", Longitude = "72.539067" });
this.imageryLayer.Markers.Add(new CustomMarker { Latitude = "22.589499", Longitude = "75.842287" });
this.imageryLayer.Markers.Add(new CustomMarker { Latitude = "22.122114", Longitude = "85.158694" });
this.imageryLayer.Markers.Add(new CustomMarker { Latitude = "17.213389", Longitude = "78.457033" });
this.imageryLayer.Markers.Add(new CustomMarker { Latitude = "10.259969", Longitude = "77.512209" });
this.CalculateZoomLevel(this.imageryLayer.Markers);
}
…
// Calculate the ZoomLevel based on the Markers collection.
private void CalculateZoomLevel(ObservableCollection<MapMarker> markers)
{
CalculateMarkerBounds(markers, out Point northEast, out Point southWest);
var center = new Point((northEast.Y + southWest.Y) / 2, (northEast.X + southWest.X) / 2);
var northEastWithPadding = new Point(northEast.X + ((northEast.X - center.X) / 2), northEast.Y + (northEast.Y - center.Y) / 2); // added half distance as padding for north east
var southWestWithPadding = new Point(southWest.X - (center.X - southWest.X) / 2, southWest.Y - (center.Y - southWest.Y) / 2); // added half distance as padding for south west
var zoomLevel = GetBoundsZoomLevel(northEastWithPadding, southWestWithPadding, sfMaps.Width, sfMaps.Height);
if (this.sfMaps.ZoomLevel == zoomLevel)
{
this.sfMaps.ZoomLevel = 1; // reset the zoom level value in order to update the property
}
sfMaps.ZoomLevel = zoomLevel;
if (imageryLayer.GeoCoordinates == center)
{
this.imageryLayer.GeoCoordinates = new Point(0, 0); // reset the center value in order to update the property
}
imageryLayer.GeoCoordinates = center;
}… |