protected override void OnMapReady(GoogleMap map) { base.OnMapReady(map); GoogleMap = map; map.UiSettings.MapToolbarEnabled = false; if (FormsMap.RoutePins != null && FormsMap.RoutePins.Count > 1) { var polylineOptions = new PolylineOptions(); polylineOptions.InvokeColor(Color.Red.ToAndroid()); foreach (var pins in FormsMap.RoutePins) { polylineOptions.Add(new LatLng(pins.Position.Latitude, pins.Position.Longitude)); } NativeMap.AddPolyline(polylineOptions); } else if (FormsMap.AvailableRegions != null) { var polygonOptions = new PolygonOptions(); polygonOptions.InvokeFillColor(Android.Graphics.Color.ParseColor("#2271cce7")); polygonOptions.InvokeStrokeColor(Android.Graphics.Color.ParseColor("#2271cce7")); polygonOptions.InvokeStrokeWidth(15.0f); foreach (var position in FormsMap.AvailableRegions) { polygonOptions.Add(new LatLng(position.Latitude, position.Longitude)); } NativeMap.AddPolygon(polygonOptions); } }
private void resetarPolyline(IList <Position> novaRota) { if (_polyline != null) { _polyline.Remove(); _polyline.Dispose(); _polyline = null; } if (NativeMap != null) { var polylineOptions = new PolylineOptions(); polylineOptions.InvokeColor(0x66FF0000); while (polylineOptions.Points != null && polylineOptions.Points.Count > 0) { polylineOptions.Points.RemoveAt(0); } if (novaRota != null) { foreach (var position in novaRota) { polylineOptions.Add(new LatLng(position.Latitude, position.Longitude)); } _polyline = NativeMap.AddPolyline(polylineOptions); } } }
//public void LoadRoutes(OverviewPolyline overview_polyline) //{ // lines = DirectionsMethods.DecodePolyline(overview_polyline.points); // FormsMap_RoutesListUpdated(this, EventArgs.Empty); //} private void FormsMap_RoutesListUpdated(object sender, EventArgs e) { if (NativeMap == null) { return; } var polylineOptions = new PolylineOptions() .InvokeColor(0x66FF0000) .InvokeWidth(6); foreach (LatLng line in Lines) { polylineOptions.Add(line); } //googleMap.AddPolyline(polylineOptions); //var polylineOptions = new PolylineOptions(); //polylineOptions.InvokeColor(0x66FF0000); //foreach (var position in routeCoordinates) //{ // polylineOptions.Add(new LatLng(position.Latitude, position.Longitude)); //} NativeMap.AddPolyline(polylineOptions); }
private void _routeCoordinates_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { //highlighting route if (e.Action == NotifyCollectionChangedAction.Add) { var latestPosition = _routeCoordinates[_routeCoordinates.Count - 1]; if (_routeCoordinates.Count > 1) { var polylineOptions = new PolylineOptions(); polylineOptions.InvokeColor(0x66FF0000); foreach (var position in _routeCoordinates) { polylineOptions.Add(new LatLng(position.Latitude, position.Longitude)); } if (NativeMap == null) { Log.Debug(TAG, "null Native Map"); } else { Log.Debug(TAG, "Native Map is not null"); Polyline polyline = NativeMap.AddPolyline(polylineOptions); } } } else { Log.Debug(TAG, "not ADD action"); } }
protected override NativePolyline CreateNativeItem(Polyline outerItem) { var opts = new PolylineOptions(); foreach (var p in outerItem.Positions) { opts.Add(new LatLng(p.Latitude, p.Longitude)); } opts.InvokeWidth(outerItem.StrokeWidth * this.ScaledDensity); // TODO: convert from px to pt. Is this collect? (looks like same iOS Maps) opts.InvokeColor(outerItem.StrokeColor.ToAndroid()); opts.Clickable(outerItem.IsClickable); opts.InvokeZIndex(outerItem.ZIndex); var nativePolyline = NativeMap.AddPolyline(opts); // associate pin with marker for later lookup in event handlers outerItem.NativeObject = nativePolyline; outerItem.SetOnPositionsChanged((polyline, e) => { var native = polyline.NativeObject as NativePolyline; native.Points = polyline.Positions.ToLatLngs(); }); return(nativePolyline); }
protected override void OnMapReady(GoogleMap map) { base.OnMapReady(map); _map = map; _map.UiSettings.MyLocationButtonEnabled = false; _map.UiSettings.ZoomControlsEnabled = false; _map.UiSettings.ZoomGesturesEnabled = true; _map.UiSettings.RotateGesturesEnabled = true; if (_map != null) { _map.MapClick += googleMapClick; } if (NativeMap != null) { var polylineOptions = new PolylineOptions(); polylineOptions.InvokeColor(0x66FF0000); foreach (var position in _polylinePosicoes) { polylineOptions.Add(new LatLng(position.Latitude, position.Longitude)); } _polyline = NativeMap.AddPolyline(polylineOptions); } if (_mapaForm != null) { if (!_inicializouMapa) { _mapaForm.inicializarMapa(); _inicializouMapa = true; } } }
private void ShowRouteOverview() { NativeMap.Clear(); PolylineOptions selectedRoutePolyline = new PolylineOptions(); selectedRoutePolyline.InvokeColor(Resource.Color.colorPrimaryDark); selectedRoutePolyline.InvokeWidth(20f); LatLng[] allRoutePoints = _xamap.SelectedRoute.Legs .SelectMany(leg => leg.Points) .Select(point => new LatLng(point.Latitude, point.Longitude)) .ToArray(); selectedRoutePolyline.Add(allRoutePoints); NativeMap.AddPolyline(selectedRoutePolyline); LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder(); LatLngBounds routeBounds = allRoutePoints .Aggregate(boundsBuilder, (builder, latLng) => builder.Include(latLng)) .Build(); CameraUpdate routeOverviewMapUpdate = CameraUpdateFactory.NewLatLngBounds(routeBounds, 50); NativeMap.AnimateCamera(routeOverviewMapUpdate); }
protected override void OnMapReady(GoogleMap map) { base.OnMapReady(map); var polylineOptions = new PolylineOptions(); polylineOptions.InvokeColor(0x702418ff); foreach (var position in routeCoordinates) { polylineOptions.Add(new LatLng(position.Latitude, position.Longitude)); } NativeMap.AddPolyline(polylineOptions); foreach (Bus bus in BusList.busList) { if (bus.route == "blue") { CircleOptions circleOptions = new CircleOptions(); circleOptions.InvokeCenter(new LatLng(bus.lat, bus.lng)); circleOptions.InvokeRadius(30); circleOptions.InvokeFillColor(0X700000ff); circleOptions.InvokeStrokeColor(0X70FFFFFF); circleOptions.InvokeStrokeWidth(5); NativeMap.AddCircle(circleOptions); } } }
private Polyline AddPolyline(PolylineOptions option) { var polyline = NativeMap.AddPolyline(option); polyline.Color = option.Color; polyline.Width = option.Width; return(polyline); }
private void Update() { foreach (var position in _formsMap.PolylineCoordinates) { _polylineOptions.Add(new LatLng(position.Latitude, position.Longitude)); } NativeMap.AddPolyline(_polylineOptions); }
private void DrawPolyline() { PolylineOptions polylineOptions = GetPolylineRenderer(); foreach (var position in _routeCoordinates) { polylineOptions.Add(new LatLng(position.Latitude, position.Longitude)); } _polyline = NativeMap.AddPolyline(polylineOptions); }
private void DrawPolylineSegment(PolylineSegment polylineSegment, int colorInt) { var polylineOptions = new PolylineOptions(); polylineOptions.InvokeColor(colorInt); polylineOptions.Add(new LatLng(polylineSegment.SnappedPointStart.Position.Latitude, polylineSegment.SnappedPointStart.Position.Longitude)); polylineOptions.Add(new LatLng(polylineSegment.SnappedPointEnd.Position.Latitude, polylineSegment.SnappedPointEnd.Position.Longitude)); NativeMap.AddPolyline(polylineOptions); }
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { try { base.OnElementPropertyChanged(sender, e); // if (!isDrawn) { //NativeMap.Clear(); NativeMap.InfoWindowClick += OnInfoWindowClick; var polylineOptions = new PolylineOptions(); polylineOptions.InvokeColor(0x66FF0000); foreach (var pin in ((CustomMap)Element).CustomPins) { BitmapDescriptor icon = BitmapDescriptorFactory.FromResource(Resource.Drawable.pin); var marker = new MarkerOptions(); marker.SetPosition(new LatLng(pin.Pin.Position.Latitude, pin.Pin.Position.Longitude)); marker.SetTitle(pin.Pin.Label); marker.SetSnippet(pin.Pin.Address); marker.SetIcon(icon); if (pin.Id != "1") { MoveAble_Marker = NativeMap.AddMarker(marker); } else { NativeMap.AddMarker(marker); } } // foreach (var position in ((CustomMap)Element).RouteCoordinates) { polylineOptions.Add(new LatLng(position.Latitude, position.Longitude)); } NativeMap.AddPolyline(polylineOptions); isDrawn = true; //Device.StartTimer(TimeSpan.FromSeconds(10), () => //{ // update(); // return true; //}); } } catch { } }
private void DrawPolyLine() { var polyLineOptions = new PolylineOptions(); polyLineOptions.InvokeColor(0x66FF0000); foreach (var position in _routeCoordinates) { polyLineOptions.Add(new LatLng(position.Latitude, position.Longitude)); } NativeMap.Clear(); NativeMap.AddPolyline(polyLineOptions); }
private void UpdatePolyLine() { var polylineOptions = new PolylineOptions(); polylineOptions.InvokeColor(0x66FF0000); foreach (var position in ((RouteMap)this.Element).RouteCoordinates) { polylineOptions.Add(new LatLng(position.Latitude, position.Longitude)); } NativeMap.AddPolyline(polylineOptions); }
protected override void OnMapReady(Android.Gms.Maps.GoogleMap map) { base.OnMapReady(map); var polylineOptions = new PolylineOptions(); polylineOptions.InvokeColor(0x66FF0000); foreach (var position in routeCoordinates) { polylineOptions.Add(new LatLng(position.Latitude, position.Longitude)); } NativeMap.AddPolyline(polylineOptions); }
private void OnMarkerClick(object sender, GoogleMap.MarkerClickEventArgs e) { if (currentLocation == null) { Console.Write("Location could not be determined"); return; } LatLng startLocation = new LatLng(currentLocation.Latitude, currentLocation.Longitude); Marker tarketMarker = e.Marker; LatLng targetLocation = tarketMarker.Position; String url = "https://maps.googleapis.com/maps/api/directions/json" + "?origin=" + startLocation.Latitude + "," + startLocation.Longitude + "&destination=" + targetLocation.Latitude + "," + targetLocation.Longitude + "&sensor=false&units=metric&mode=walking" + "&key=" + Resources.GetString(Resource.String.maps_api_key); // Get json data from the internet WebRequest request = WebRequest.Create(url); WebResponse response = request.GetResponseAsync().Result; Stream stream = response.GetResponseStream(); // Read json string from stream string JsonResponse = new StreamReader(stream).ReadToEnd(); PolyRoute PolyRoute = JsonConvert .DeserializeObject <PolyRoute>(JsonResponse); Step[] Steps = PolyRoute.routes[0].legs[0].steps; var RouteOptions = new PolylineOptions(); RouteOptions.InvokeColor(Android.Graphics.Color.Blue); RouteOptions.Add(new LatLng(Steps[0].start_location.lat, Steps[0].start_location.lng)); foreach (Step Step in Steps) { RouteOptions.Add(new LatLng(Step.end_location.lat, Step.end_location.lng)); } if (polyline != null) { polyline.Remove(); } polyline = NativeMap.AddPolyline(RouteOptions); }
private void DrawRoute() { var polylineOptions = new PolylineOptions(); polylineOptions.InvokeColor(0x66000000); var coordinates = _map.RouteCoordinates; coordinates?.ForEach(position => polylineOptions.Add(new LatLng(position.Latitude, position.Longitude))); if (coordinates != null) { NativeMap.AddPolyline(polylineOptions); } }
private void FormsMap_AddedPosition(object sender, NewPositionEventArgs e) { if (_isMapReady == true && routeCoordinates.Count() > 0 && e.ShowPath == true && routeCoordinates.Last() is Position lastPos) { if (NativeMap != null) { var polylineOptions = new PolylineOptions(); polylineOptions.InvokeColor(_mapLineColor); polylineOptions.Add(new LatLng(lastPos.Latitude, lastPos.Longitude)); polylineOptions.Add(new LatLng(e.Position.Latitude, e.Position.Longitude)); NativeMap.AddPolyline(polylineOptions); } } routeCoordinates.Add(e.Position); }
/*private void OnInfoWindowClick(object sender, GoogleMap.InfoWindowClickEventArgs e) * { * Xamarin.Forms.MessagingCenter.Send<MapOpenPointMessage>(new MapOpenPointMessage() { Latitude = e.Marker.Position.Latitude, Longitude = e.Marker.Position.Longitude }, string.Empty); * }*/ private void drawConnectedLines() { List <PatternItem> pattern_lines = new List <PatternItem>(); pattern_lines.Add(new Gap(10)); pattern_lines.Add(new Dash(15)); PolylineOptions lineOptions = new PolylineOptions(); foreach (var point in trackMapContext.RoutePoints) { lineOptions.Add(new LatLng(point.Latitude, point.Longitude)); } lineOptions.InvokePattern(pattern_lines); lineOptions.InvokeWidth(10); NativeMap.AddPolyline(lineOptions); }
// Customize the rendering of our Polyline overlay within the map protected override void OnMapReady(Android.Gms.Maps.GoogleMap map) { base.OnMapReady(map); var polylineOptions = new PolylineOptions(); polylineOptions.InvokeColor(0x66FF0000); // Extract each position from our RouteCoordinates List foreach (var position in formsMap.RouteCoordinates) { // Add each Latitude and Longitude position to our // PolylineOptions polylineOptions.Add(new LatLng(position.Latitude, position.Longitude)); } // Finally, add the Polyline to our map NativeMap.AddPolyline(polylineOptions); }
private void RenderPolylines() { System.Diagnostics.Debug.WriteLine("Render Polylines"); // 色指定 var polylineOptions = new PolylineOptions(); polylineOptions.InvokeColor(0x66FF0000); foreach (var pos in routeCoordinates) { polylineOptions.Add(new LatLng(pos.Latitude, pos.Longitude)); } // 描画 NativeMap.AddPolyline(polylineOptions); }
protected override void OnMapReady(GoogleMap map) { base.OnMapReady(map); NativeMap.InfoWindowClick += OnInfoWindowClick; NativeMap.SetInfoWindowAdapter(this); var polylineOptions = new PolylineOptions(); polylineOptions.InvokeColor(0x66FF0000); foreach (var position in routeCoordinates) { polylineOptions.Add(new LatLng(position.Latitude, position.Longitude)); } NativeMap.AddPolyline(polylineOptions); }
protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); if (e.PropertyName.Equals("VisibleRegion") && !isDrawn) { var polylineOptions = new PolylineOptions(); polylineOptions.InvokeColor(0x66FF0000); foreach (var position in routeCoordinates) { polylineOptions.Add(new LatLng(position.Latitude, position.Longitude)); } NativeMap.AddPolyline(polylineOptions); isDrawn = true; } }
/// <summary> /// Adds a polyline path based on helicopter destination and current position /// </summary> /// <param name="heliPin"></param> private void addFlightPath(CustomPin heliPin) { var currentFlightPathOptions = new PolylineOptions(); // Other colour constants can be found at https://developer.android.com/reference/android/graphics/Color#constants_1 int BLUE = -16776961; currentFlightPathOptions.InvokeColor(BLUE); // Add current position (start of path) currentFlightPathOptions.Add(new LatLng(heliPin.Position.Latitude, heliPin.Position.Longitude)); // Add destination position (end of path) currentFlightPathOptions.Add(new LatLng(heliPin.HelicopterDetails.destinationPosition.Latitude, heliPin.HelicopterDetails.destinationPosition.Longitude)); highlightedFlightPath = new Tuple <CustomPin, Polyline>(heliPin, NativeMap.AddPolyline(currentFlightPathOptions)); }
private void DrawRoute() { if (routeCoordinates?.Any() != true) { return; } var polylineOptions = new PolylineOptions(); polylineOptions.InvokeColor(System.Drawing.Color.Orange.ToArgb()); foreach (var position in routeCoordinates) { polylineOptions.Add(new LatLng(position.Latitude, position.Longitude)); } NativeMap.AddPolyline(polylineOptions); }
private void FormsMap_RenderEvent(object sender, ICollection <Position> e) { if (line != null) { line.Remove(); } var polylineOptions = new PolylineOptions(); polylineOptions.InvokeColor(0xffba00); polylineOptions.InvokeWidth(polylineOptions.Width + 4); foreach (var position in e) { polylineOptions.Add(new LatLng(position.Latitude, position.Longitude)); } line = NativeMap.AddPolyline(polylineOptions); }
protected override void OnMapReady(GoogleMap map) { base.OnMapReady(map); NativeMap.TrafficEnabled = true; NativeMap.UiSettings.CompassEnabled = true; NativeMap.MyLocationEnabled = true; var polylineOptions = new PolylineOptions(); polylineOptions.InvokeColor(0x66000000); foreach (var position in routeCoordinates) { polylineOptions.Add(new LatLng(position.Latitude, position.Longitude)); } NativeMap.AddPolyline(polylineOptions); }
protected override void OnMapReady(Android.Gms.Maps.GoogleMap map) { base.OnMapReady(map); var polylineOptions = new PolylineOptions(); polylineOptions.InvokeColor(0x66FF0000); foreach (var position in routeCoordinates) { polylineOptions.Add(new LatLng(position.Latitude, position.Longitude)); } NativeMap.AddPolyline(polylineOptions); NativeMap.UiSettings.ZoomControlsEnabled = false; NativeMap.UiSettings.ZoomGesturesEnabled = true; NativeMap.UiSettings.MyLocationButtonEnabled = false; NativeMap.UiSettings.RotateGesturesEnabled = false; }
protected override void OnMapReady(Android.Gms.Maps.GoogleMap map) { base.OnMapReady(map); _isMapReady = true; if (NativeMap != null) { var polylineOptions = new PolylineOptions(); polylineOptions.InvokeColor(_mapLineColor); foreach (var position in routeCoordinates) { polylineOptions.Add(new LatLng(position.Latitude, position.Longitude)); } NativeMap.AddPolyline(polylineOptions); NativeMap.UiSettings.MyLocationButtonEnabled = false; } }