public void DesenharRota(JObject rotaEscolhida) { foreach (Polyline linha in this.PolylinesCaminhoParaVaga) { try { linha.Remove(); } catch { } } RotaAtual = rotaEscolhida; string polylineString = (rotaEscolhida["overview_polyline"])["points"].ToString(); var polyline = GooglePoints.Decode(polylineString); PolylineOptions opt = new PolylineOptions(); foreach (var point in polyline) { opt = opt.Add(point); } ; opt = opt.InvokeWidth(20); opt = opt.InvokeColor(this.CorLinhaEstrada); this.PolylinesCaminhoParaVaga.Add(Mapa.AddPolyline(opt)); }
public void UpdatePolyLinePos(bool init, LatLng pos = null) { if (targetLine != null) { targetLine.Remove(); targetLine.Dispose(); } var polylineOptions = new PolylineOptions(); polylineOptions.Clickable(true); polylineOptions.InvokeJointType(JointType.Round);//don't see the difference polylineOptions.InvokeWidth(10f); polylineOptions.InvokeColor(0x664444FF); int i = 0; CustomMap customMap = (CustomMap)this.Element; if (customMap != null) { foreach (var position in customMap.RouteCoordinates) { if (i == 1 && !init && pos != null) { polylineOptions.Add(pos); } else { polylineOptions.Add(new LatLng(position.Latitude, position.Longitude)); } i++; } targetLine = map.AddPolyline(polylineOptions); } }
void FnSetDirectionQuery(string strJSONDirectionResponse) { //var txtResult = FindViewById<TextView>(Resource.Id.textResult); var objRoutes = JsonConvert.DeserializeObject <GoogleDirectionClass>(strJSONDirectionResponse); //objRoutes.routes.Count --may be more then one //if (objRoutes.routes.Count != 0) if (true) { //string encodedPoints = objRoutes.routes[0].overview_polyline.points; //List<LatLng> lstDecodedPoints = DecodePolyline(encodedPoints); List <LatLng> lstDecodedPoints = DecodePolyline("yf}`Bk|osS}E\\kBFo@UEEOCMFCNDLDB@?FjBNxAH~@z@xMh@~Hl@|GNtCHbAGXUr@wDnHcDxFY\\_@\\I@OBUNINkBNwBXgCTiHf@k@D}BXuAd@yAp@k@d@_@`@Uf@CAEAQAQDONCLAR@BKLU`@OPg@^eAn@SH_Cn@q@Na@PCCEEOCOBKNAH?BYLuE`ByD|AcJ|EsBx@_JxCoBt@o@n@@^@tBFzEP|@D~BHxEExGKhFIpDE~FSrIEvBC`E@tCT|GlCAXbJ`Bi@bAo@NGKi@?E?CDE@G"); var polylineOptions = new PolylineOptions(); polylineOptions = new PolylineOptions(); polylineOptions.InvokeColor(global::Android.Graphics.Color.Red); polylineOptions.InvokeWidth(4); foreach (LatLng line in lstDecodedPoints) { polylineOptions.Add(line); } map.AddPolyline(polylineOptions); } }
void AddPolylines(IList polylines) { var map = NativeMap; if (map == null) { return; } if (_polylines == null) { _polylines = new List <APolyline>(); } _polylines.AddRange(polylines.Cast <Polyline>().Select(line => { var polyline = (Polyline)line; var opts = new PolylineOptions(); foreach (var p in polyline.Positions) { opts.Add(new LatLng(p.Latitude, p.Longitude)); } opts.InvokeWidth(polyline.StrokeWidth * _scaledDensity); // TODO: convert from px to pt. Is this collect? (looks like same iOS Maps) opts.InvokeColor(polyline.StrokeColor.ToAndroid()); opts.Clickable(polyline.IsClickable); var nativePolyline = map.AddPolyline(opts); // associate pin with marker for later lookup in event handlers polyline.Id = nativePolyline; return(nativePolyline); })); }
private void PolylineDemo(HuaweiMap hMap) { hMap.Clear(); Polyline polyline1; PolylineOptions polyline1Options = new PolylineOptions() .Add(new LatLng(41.01929, 28.967267), new LatLng(41.016785, 28.986971), new LatLng(41.001917, 28.978743), new LatLng(41.002298, 28.954132)); polyline1Options.InvokeColor(Color.Blue); polyline1Options.InvokeWidth(20); // polyline1Options.InvokeZIndex(2); polyline1Options.Visible(false); polyline1Options.Clickable(true); polyline1 = hMap.AddPolyline(polyline1Options); Polyline polyline2; PolylineOptions polyline2Options = new PolylineOptions() .Add(new LatLng(41.010410, 28.978511), new LatLng(41.035243, 29.026812), new LatLng(41.022122, 29.00653), new LatLng(41.00415, 29.012449), new LatLng(41.001699, 28.978743)); polyline2Options.InvokeColor(Color.Red); polyline1Options.InvokeZIndex(1); polyline2Options.Clickable(true); polyline2 = hMap.AddPolyline(polyline2Options); }
void DibujarRuta() { try { var options = new PolylineOptions(); var colorInt = Colores.Accent; options.InvokeColor(colorInt); options.InvokeWidth(5); options.Visible(true); foreach (var posicion in _posiciones.OrderBy(p => p.Fecha)) { var coordenada = posicion.Coordenada; options.Add(new LatLng(coordenada.Latitud, coordenada.Longitud)); } _mapa.AddPolyline(options); } catch (Exception ex) { AlertMessage.Show(Activity, $"Ha ocurrido un error: {ex.Message}", ToastLength.Long); } }
public void OnMapReady(GoogleMap googleMap) { map = googleMap; var polylineOptions = new PolylineOptions(); polylineOptions.InvokeColor(0x66FF0000); foreach (var position in calculatedRoute) { polylineOptions.Add(new LatLng(position.Lat, position.Lon)); } map.AddPolyline(polylineOptions); polylineOptions = new PolylineOptions(); polylineOptions.InvokeColor(customerapp.Droid.Resource.Color.green); polylineOptions.InvokeWidth(10); foreach (var position in flownRoute) { polylineOptions.Add(new LatLng(position.Lat, position.Lon)); } map.AddPolyline(polylineOptions); }
public async Task GetRouteInfo(LatLng origin, LatLng destination) { string response = string.Empty; await Task.Run(() => { URL url = new URL(string.Format("https://maps.googleapis.com/maps/api/directions/json?" + "origin={0},{1}&destination={2},{3}&mode=walking&key={4}", origin.Latitude, origin.Longitude, destination.Latitude, destination.Longitude, "AIzaSyCgx1MivNMRG1zVWd93Uu0XwysGsmAlxt8")); HttpsURLConnection urlConnection = (HttpsURLConnection)url.OpenConnection(); urlConnection.Connect(); var stream = urlConnection.InputStream; using (var streamReader = new StreamReader(stream)) { response = streamReader.ReadToEnd(); } return(response); }); PolylineOptions polylines = GetPolylines(response); polylines.InvokeColor(-65536); polylines.InvokeWidth(5); _googleMap.AddPolyline(polylines); }
private void ColocarNovoPontoMapa(LatLng latlngOrigem, LatLng latlngDest, JObject estacionamento) { MarkerOptions options = new MarkerOptions().SetPosition(latlngOrigem).SetTitle("").SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.dot)); Marker ponto = GMap.AddMarker(options); Marcador marcador = new Marcador(estacionamento, ponto); if (latlngDest != null) { var _latitude = latlngDest.Latitude; var _longitude = latlngDest.Longitude; //var _altitude = (ponto["Localizacao"])["Altitude"].Value<double>(); PolylineOptions opt = new PolylineOptions(); opt = opt.Add(latlngOrigem, new LatLng(_latitude, _longitude)); opt = opt.InvokeWidth(5); opt = opt.InvokeColor(Color.Red); Polyline line = GMap.AddPolyline(opt); marcador.Linhas.Add(line); } if (UltimoPontoInteracao != null) { marcador.Conexoes.Add(long.Parse(UltimoPontoInteracao.Title)); } marcador = SalvarPontoInserido(marcador); UltimoPontoInteracao = marcador.Marker; this.MarcadoresColocados.Add(marcador); }
private void MostrarVagasNoMapa(JObject ponto, JArray lista) { if (lista != null) { foreach (var vaga in lista) { var latitude = (vaga["Localizacao"])["Latitude"].Value <double>(); var longitude = (vaga["Localizacao"])["Longitude"].Value <double>(); var altitude = (vaga["Localizacao"])["Altitude"].Value <double>(); LatLng latlng = new LatLng(Convert.ToDouble(latitude), Convert.ToDouble(longitude)); MarkerOptions options = new MarkerOptions().SetPosition(latlng).SetTitle(vaga["Numero"].Value <long>().ToString()); GMap.AddMarker(options); var _latitude = (ponto["Localizacao"])["Latitude"].Value <double>(); var _longitude = (ponto["Localizacao"])["Longitude"].Value <double>(); var _altitude = (ponto["Localizacao"])["Altitude"].Value <double>(); PolylineOptions opt = new PolylineOptions(); opt = opt.Add(new LatLng(latitude, longitude), new LatLng(_latitude, _longitude)); opt = opt.InvokeWidth(5); opt = opt.InvokeColor(Color.Blue); Polyline line = GMap.AddPolyline(opt); } } }
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 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); }
private PolylineOptions GetLine() { PolylineOptions lineOptions = new PolylineOptions(); lineOptions.InvokeColor(0x660000FF); lineOptions.InvokeWidth(5); return(lineOptions); }
private static PolylineOptions GetPolylineRenderer() { var polylineOptions = new PolylineOptions(); polylineOptions.InvokeColor(0x66FF0000); polylineOptions.InvokeWidth(10.0f); return(polylineOptions); }
private static PolylineOptions CloneOptions(PolylineOptions op) { var options = new PolylineOptions(); options.InvokeColor(op.Color); options.InvokeWidth(op.Width); options.InvokeZIndex(op.ZIndex); return(options); }
private PolylineOptions CreatePolylineOptions(MapPolyline polyline) { var op = new PolylineOptions(); op.InvokeColor(polyline.Color.ToAndroid().ToArgb()); op.InvokeWidth((float)polyline.Width); op.InvokeZIndex(polyline.ZIndex); return(op); }
protected override void OnStart() { int i = 0; base.OnStart(); // this.AttachEvents(); this.mapView.OnStart(); if (this.firstLoad) { this.firstLoad = false; this.performOperatoinOnMap((map) => { this.Map = map; this.Map.UiSettings.RotateGesturesEnabled = false; this.Map.SetOnMapClickListener(this); //this.Map.SetOnMarkerClickListener(this); this.Map.SetOnScrollListener(this); this.ZoomToDefaultView(); var position = new CameraPosition.Builder() .Target(new LatLng(28.60831, 77.36114)) .Zoom(8) .Build(); foreach (var item in lstLatLng) { markerViewOptions = new MarkerViewOptions(); markerViewOptions.InvokeIcon(StoppedIcon); markerViewOptions.InvokePosition(item); markerViewOptions.InvokeRotation((float)item.Latitude); markerViewOptions.InvokeSnippet("Well come to RSystem"); markerViewOptions.InvokeTitle("RSystem"); Map.AddMarker(markerViewOptions); // lstMarker.Add(markerViewOptions); polylineOptions.Add(item); polylineOptions.InvokeWidth(5); if (i % 2 == 0) { polylineOptions.InvokeColor(Color.Red); } else { polylineOptions.InvokeColor(Color.Green); } // lstPolyline.Add(polylineOptions); // Map.AddPolyline(polylineOptions); i++; } // Map.AddPolylines(lstPolyline); this.Map.MoveCamera(CameraUpdateFactory.NewCameraPosition(position)); }); } }
private void MostrarVagasNoMapa(long idEstacionamento, JObject ponto, JArray lista) { if (lista != null) { foreach (var vaga in lista) { Vaga _vaga = new Vaga(); var latitude = (vaga["Localizacao"])["Latitude"].Value <double>(); var longitude = (vaga["Localizacao"])["Longitude"].Value <double>(); var altitude = (vaga["Localizacao"])["Altitude"].Value <double>(); LatLng latlng = new LatLng(Convert.ToDouble(latitude), Convert.ToDouble(longitude)); int icone = 0; switch (vaga["Tipo"].Value <int>()) { default: icone = Resource.Drawable.parking_sign; //vaga normal; break; case 1: icone = Resource.Drawable.parking_sign_special_1; //vaga idoso; break; case 2: icone = Resource.Drawable.parking_sign_special_2; //vaga especial; break; } var ocupacao = vaga["Ocupacao"]; MarkerOptions options = new MarkerOptions().SetPosition(latlng).SetTitle(vaga["Numero"].Value <long>().ToString()).SetIcon(BitmapDescriptorFactory.FromResource(icone)); _vaga.Marker = Mapa.AddMarker(options); _vaga.Ponto = ponto; _vaga.Dados = vaga; _vaga.IdEstacionamento = idEstacionamento; VagasColocadas.Add(_vaga); ChecarVisibilidadeVaga(_vaga); var _latitude = (ponto["Localizacao"])["Latitude"].Value <double>(); var _longitude = (ponto["Localizacao"])["Longitude"].Value <double>(); var _altitude = (ponto["Localizacao"])["Altitude"].Value <double>(); PolylineOptions opt = new PolylineOptions(); opt = opt.Add(new LatLng(latitude, longitude), new LatLng(_latitude, _longitude)); opt = opt.InvokeWidth(5); opt = opt.InvokeColor(this.CorLinhaCaminhoEstacionamento); Polyline line = Mapa.AddPolyline(opt); } } }
protected virtual PolylineOptions CreatePolylineOptions(Polyline polyline) { var opts = new PolylineOptions(); opts.InvokeColor(polyline.StrokeColor.ToAndroid(Color.Black)); opts.InvokeWidth(polyline.StrokeWidth); foreach (var position in polyline.Geopath) { opts.Points.Add(new LatLng(position.Latitude, position.Longitude)); } return(opts); }
private void CreateDashedLine(List <LatLng> coords) { for (var i = 0; i < (coords.Count - 1); i += 2) { var nextLine = new ArrayList(); nextLine.Add(coords[i]); nextLine.Add(coords[i + 1]); var polyline = new PolylineOptions(); polyline.AddAll(nextLine); polyline.InvokeWidth(2); polyline.InvokeColor(Color.Gray); mapboxMap.AddPolyline(polyline); } }
private void AddPolylines() { // 绘制一个虚线三角形 var polylineOptions = new PolylineOptions(); //添加坐标点,按照点的顺序依次连接 // 如果点已经在列表中,您可以调用 PolylineOptions.addAll() 方法 polylineOptions.Add(new LatLng(30.779879, 104.064855)); polylineOptions.Add(new LatLng(39.936713, 116.386475)); polylineOptions.Add(new LatLng(39.02, 120.51)); //InvokeWidth :设置宽度; //SetDottedLine:设置虚线; polylineOptions.InvokeWidth(10).SetDottedLine(true).Geodesic(true).InvokeColor(Color.Argb(255, 1, 1, 1)); aMap.AddPolyline(polylineOptions); }
protected override void DrawPolyline(List <GeoLoc> polyLine) { if (polyLine == null || polyLine.Count == 0) { return; } var map = _mapFragment.Map; // draw routes PolylineOptions options = new PolylineOptions().Geodesic(true); if (polyLine == _highlighedPoint.Polyline) { options.InvokeWidth(7); options.InvokeColor(System.Drawing.Color.Blue.ToArgb()); } else { options.InvokeWidth(3); options.InvokeColor(System.Drawing.Color.LightBlue.ToArgb()); } polyLine.ForEach(x => options.Add(Utils.GetLatLng(x))); _routeLines.Add(map.AddPolyline(options)); }
public void OnMapReady(GoogleMap googleMap) { if (routeCoordinates.Count != 0) { map = googleMap; var polylineOptions = new PolylineOptions(); polylineOptions.InvokeColor(0x66FF0000); polylineOptions.InvokeWidth(15f); foreach (var position in routeCoordinates) { polylineOptions.Add(new LatLng(position.Latitude, position.Longitude)); } map.AddPolyline(polylineOptions); } }
protected override void OnMapReady(Android.Gms.Maps.GoogleMap map) { base.OnMapReady(map); var polylineOptions = new PolylineOptions(); polylineOptions.InvokeColor(-16776961); polylineOptions.InvokeWidth(20); foreach (var position in routeCoordinates) { polylineOptions.Add(new LatLng(position.Latitude, position.Longitude)); } NativeMap.AddPolyline(polylineOptions); }
/*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); }
private void AddLegs(List <Leg> legs, List <SnappedSpan> snappedSpan) { foreach (var span in snappedSpan) { PolylineOptions rectOptions = new PolylineOptions(); rectOptions.InvokeWidth(7); rectOptions.InvokeColor(Color.Blue.ToArgb()); foreach (var point in span.snappedPoints) { rectOptions.Add(new LatLng(point.location.latitude, point.location.longitude)); } map.AddPolyline(rectOptions); } }
private void addConePolyline(double angle, GeodeticCalculator geoCalculator, CustomMap customMap, LatLng userPos, double distTarget) { var polylineOptions = new PolylineOptions(); polylineOptions.Clickable(true); polylineOptions.InvokeJointType(JointType.Round); polylineOptions.InvokeWidth(10f); polylineOptions.InvokeColor(0x664444FF); polylineOptions.Add(userPos); LatLng conePoint = movePoint(angle, customMap.UserPin.Position, customMap.TargetPin.Position); Console.WriteLine("conePoint dist = " + CustomMap.DistanceTo(customMap.UserPin.Position.Latitude, customMap.UserPin.Position.Longitude, conePoint.Latitude, conePoint.Longitude, "M")); polylineOptions.Add(conePoint); coneLines.Add(map.AddPolyline(polylineOptions)); }
/// <summary> /// Draw line from active location to active object, if it is a zone. /// </summary> void UpdateDistanceLine() { if (activeObject != null && activeObject is Zone) { if (activeObject is Zone && ((Zone)activeObject).State != PlayerZoneState.Inside) { if (distanceLine == null) { // Draw line PolylineOptions po = new PolylineOptions(); po.Points.Add(new LatLng(Main.GPS.Location.Latitude, Main.GPS.Location.Longitude)); po.Points.Add(new LatLng(((Zone)activeObject).ObjectLocation.Latitude, ((Zone)activeObject).ObjectLocation.Longitude)); //.ObjectLocation.Latitude, ((Zone)activeObject).ObjectLocation.Longitude)); po.InvokeColor(Color.Cyan); po.InvokeWidth(4); po.InvokeZIndex(2); distanceLine = _map.AddPolyline(po); } else { // Set new line points List <LatLng> points = new List <LatLng>(2); points.Add(new LatLng(Main.GPS.Location.Latitude, Main.GPS.Location.Longitude)); points.Add(new LatLng(((Zone)activeObject).ObjectLocation.Latitude, ((Zone)activeObject).ObjectLocation.Longitude)); //.ObjectLocation.Latitude, ((Zone)activeObject).ObjectLocation.Longitude)); distanceLine.Points = points; } } else { // Delete line if (distanceLine != null) { distanceLine.Remove(); distanceLine = null; } } } else { // Delete line if (distanceLine != null) { distanceLine.Remove(); distanceLine = null; } } }
public void OnMapReady(GoogleMap map) { googleMap = map; googleMap.UiSettings.ZoomControlsEnabled = true; googleMap.UiSettings.CompassEnabled = true; googleMap.UiSettings.MyLocationButtonEnabled = false; AddMarkersToMap(); //animateToLocationButton.Click += AnimateToPasschendaele; PolylineOptions RF_polyline = new PolylineOptions() .Add(new LatLng(-12.082553, -76.934275)) .Add(new LatLng(-12.082270, -76.935533)) .Add(new LatLng(-12.082287, -76.935816)) .Add(new LatLng(-12.084463, -76.938913)) ; PolylineOptions GL_polyline = new PolylineOptions() .Add(new LatLng(-12.075163, -76.957738)) .Add(new LatLng(-12.075981, -76.958245)) .Add(new LatLng(-12.075745, -76.959329)) .Add(new LatLng(-12.075750, -76.960557)) ; PolylineOptions JP_polyline = new PolylineOptions() .Add(new LatLng(-12.070950, -76.955305)) .Add(new LatLng(-12.071475, -76.956480)) .Add(new LatLng(-12.071868, -76.957333)) .Add(new LatLng(-12.073699, -76.961399)) ; RF_polyline.InvokeColor(Color.Orange); JP_polyline.InvokeColor(Color.Red); GL_polyline.InvokeColor(Color.Green); RF_polyline.InvokeWidth(35.0f); JP_polyline.InvokeWidth(35.0f); GL_polyline.InvokeWidth(35.0f); map.AddPolyline(JP_polyline); map.AddPolyline(RF_polyline); map.AddPolyline(GL_polyline); }
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); }