Пример #1
0
 public static void Add(this PolylineOptions options, Position pos)
 {
     using (var latlng = pos.ToLatLng())
     {
         options.Add(latlng);
     }
 }
Пример #2
0
        /// <summary>
        /// Render the route planning result
        /// </summary>
        /// <param name="paths">paths</param>
        /// <param name="latLngBounds">latLngBounds</param>
        private void renderRoute(List <List <LatLng> > paths, LatLngBounds latLngBounds)
        {
            if (paths == null || paths.Count <= 0 || paths.ElementAt(0).Count <= 0)
            {
                return;
            }

            for (int i = 0; i < paths.Count; i++)
            {
                List <LatLng>   path    = paths.ElementAt(i);
                PolylineOptions options = new PolylineOptions().InvokeColor(Color.Blue).InvokeWidth(5);
                foreach (LatLng latLng in path)
                {
                    options.Add(latLng);
                }

                Polyline polyline = hMap.AddPolyline(options);
                mPolylines.Add(polyline);
            }

            AddOriginMarker(paths.ElementAt(0).ElementAt(0));
            AddDestinationMarker(paths.ElementAt(0).ElementAt(paths.ElementAt(0).Count - 1));

            if (null != latLngBounds)
            {
                CameraUpdate cameraUpdate = CameraUpdateFactory.NewLatLngBounds(latLngBounds, 5);
                hMap.MoveCamera(cameraUpdate);
            }
            else
            {
                hMap.MoveCamera(CameraUpdateFactory.NewLatLngZoom(paths.ElementAt(0).ElementAt(0), 13));
            }
        }
Пример #3
0
        public void OnMapReady(GoogleMap googleMap)
        {
            List <List <Localization> > Localizations = new List <List <Localization> >();

            LatLngBounds.Builder builder = new LatLngBounds.Builder();
            if (Training.SerializedLocalizations != null && Training.SerializedLocalizations.Length > 0)
            {
                IFormatter formatter = new BinaryFormatter();
                using (MemoryStream stream = new MemoryStream(Training.SerializedLocalizations))
                {
                    Localizations = formatter.Deserialize(stream) as List <List <Localization> >;
                }
            }
            foreach (var path in Localizations)
            {
                PolylineOptions options = new PolylineOptions()
                                          .InvokeColor((new Color(105, 121, 176, 200).ToArgb()))
                                          .InvokeWidth(20);
                foreach (var point in path)
                {
                    options.Add(new LatLng(point.Latitude, point.Longitude));
                    builder.Include(new LatLng(point.Latitude, point.Longitude));
                }
                googleMap.AddPolyline(options);
            }
            LatLngBounds bounds = builder.Build();
            // begin new code:
            int width   = Resources.DisplayMetrics.WidthPixels;
            int height  = Resources.DisplayMetrics.HeightPixels;
            int padding = (int)(width * 0.05);

            CameraUpdate cameraUpdate = CameraUpdateFactory.NewLatLngBounds(bounds, width, height, padding);

            googleMap.AnimateCamera(cameraUpdate);
        }
Пример #4
0
        public void DisplayItinerary(Itinerary ItineraryToShow)
        {
            List <Leg>    LegsToShow = ItineraryToShow.legs;
            List <LatLng> points     = new List <LatLng>();
            int           index      = 1;

            foreach (var leg in LegsToShow)
            {
                List <LatLng> legpoints = new List <LatLng>();
                foreach (var coord in leg.googlePoints)
                {
                    LatLng newCoord = new LatLng(coord.Latitude, coord.Longitude);
                    points.Add(newCoord);
                    legpoints.Add(newCoord);
                }

                var legPolyline = new PolylineOptions().Visible(true).InvokeColor(Color.Red).InvokeWidth(5);
                legPolyline.Add(legpoints.ToArray());

                polylineDictionary.Add(index, legPolyline);
                fromNameDictionary.Add(index, leg.from);
                toNameDictionary.Add(index, leg.to);
                modeDictionary.Add(index, leg.mode);
                index++;
            }

            PolylineOptions polyline = new PolylineOptions().Visible(true).InvokeColor(Color.Red).InvokeWidth(5);

            polyline.Add(points.ToArray());

            polylineDictionary.Add(0, polyline);
            fromNameDictionary.Add(0, ItineraryToShow.legs[0].from);
            toNameDictionary.Add(0, ItineraryToShow.legs[ItineraryToShow.legs.Count - 1].to);
            modeDictionary.Add(0, "none");
        }
Пример #5
0
        protected override void OnMapReady(GoogleMap map)
        {
            base.OnMapReady(map);

            var polylineOptions = new PolylineOptions();

            polylineOptions.InvokeColor(0x700ace00);

            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 == "green")
                {
                    CircleOptions circleOptions = new CircleOptions();
                    circleOptions.InvokeCenter(new LatLng(bus.lat, bus.lng));
                    circleOptions.InvokeRadius(30);
                    circleOptions.InvokeFillColor(0X70008000);
                    circleOptions.InvokeStrokeColor(0X70FFFFFF);
                    circleOptions.InvokeStrokeWidth(5);

                    NativeMap.AddCircle(circleOptions);
                }
            }
        }
Пример #6
0
        private LatLngBounds findMapBounds(PolylineOptions polyOptions)
        {
            double maxLat = -10000;
            double maxLon = -10000;
            double minLat = 10000;
            double minLon = 10000;

            foreach (LatLng latLon in polyOptions.Points)
            {
                if (latLon.Latitude > maxLat)
                {
                    maxLat = latLon.Latitude;
                }

                if (latLon.Latitude < minLat)
                {
                    minLat = latLon.Latitude;
                }

                if (latLon.Longitude > maxLon)
                {
                    maxLon = latLon.Longitude;
                }

                if (latLon.Longitude < minLon)
                {
                    minLon = latLon.Longitude;
                }
            }

            LatLng southWestLatLng = new LatLng(minLat, minLon);
            LatLng northEastLatLng = new LatLng(maxLat, maxLon);

            return(new LatLngBounds(southWestLatLng, northEastLatLng));
        }
Пример #7
0
        private void Spinner_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)
        {
            UniversityBuilding dest = Adapter.GetItem(e.Position);

            latLngDestination = new LatLng(dest.Latitude, dest.Longitude);

            FnUpdateCameraPosition(latLngSource);

            Activity.RunOnUiThread(() =>
            {
                if (map != null)
                {
                    map.Clear();
                    MarkOnMap("MyLocation", latLngSource, Resource.Drawable.MarkerSource);
                    MarkOnMap(dest.BuildingName, latLngDestination, Resource.Drawable.MarkerDest);
                }
            });

            PolylineOptions polylineoption = new PolylineOptions();

            polylineoption.InvokeColor(Android.Graphics.Color.Red);
            //polylineoption.Geodesic(true);
            polylineoption.Add(latLngSource, latLngDestination);
            Activity.RunOnUiThread(() =>
                                   map.AddPolyline(polylineoption));
        }
Пример #8
0
        addAlignmentFromPoly(string nameAlign, string nameLayer, ObjectId idPoly, string nameStyle, string nameLabelStyle, bool eraseEx, bool addCurves = false)
        {
            Alignment       align = null;
            PolylineOptions opts  = new PolylineOptions();

            opts.AddCurvesBetweenTangents = addCurves;
            opts.EraseExistingEntities    = eraseEx;
            opts.PlineId = idPoly;
            Layer.manageLayers(nameLayer);
            try
            {
                using (BaseObjs._acadDoc.LockDocument())
                {
                    using (Transaction tr = BaseObjs.startTransactionDb())
                    {
                        ObjectId id = Alignment.Create(BaseObjs._civDoc, opts, nameAlign, null, nameLayer, nameStyle, nameLabelStyle);
                        align = (Alignment)tr.GetObject(id, OpenMode.ForWrite);
                        align.ReferencePointStation = 1000;
                        tr.Commit();
                    }
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(string.Format("{0} Align.cs: line: 35", ex.Message));
            }
            return(align);
        }
        public async void FindRouteAsync(string source, string destrination) // radi sa primerom https://maps.googleapis.com/maps/api/directions/json?origin=Brooklyn&destination=Queens&mode=transit&key=AIzaSyDY8RF7Oa9h5IeD7DX6l_GtGPnjT6J7k4U
        {
            client = new HttpClient();
            // string default_for_every_query = "https://maps.googleapis.com/maps/api/directions/json?";

            HttpResponseMessage response = await client.GetAsync("https://maps.googleapis.com/maps/api/directions/json?origin=" + source + "&destination=" + destrination + "&mode=transit&key=AIzaSyDY8RF7Oa9h5IeD7DX6l_GtGPnjT6J7k4U");

            if (response.StatusCode == HttpStatusCode.OK)
            {
                HttpContent content = response.Content;
                var         json    = await content.ReadAsStringAsync();

                Console.WriteLine(json.ToString());

                JSONObject    jsonresoult       = new JSONObject(json);
                JSONArray     routesArray       = jsonresoult.GetJSONArray("routes");
                JSONObject    routes            = routesArray.GetJSONObject(0);
                JSONObject    overviewPolylines = routes.GetJSONObject("overview_polyline");
                String        encodedString     = overviewPolylines.GetString("points");
                List <LatLng> list = decodePoly(encodedString);

                PolylineOptions po = new PolylineOptions();
                //treba i < list.Count zasto puca sa tim?

                for (int i = 0; i < list.Count; i++)
                {
                    po.Add(list[i]).InvokeWidth(10).InvokeColor(0x66FF0000);//red color
                }

                gmap.AddPolyline(po);
            }
        }
        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;
                }
            }
        }
Пример #11
0
        public void DrawPolyLines(string json)
        {
            var directionData = JsonConvert.DeserializeObject <DirectionParser>(json);

            // Decode Encoded Route
            var points = directionData.routes[0].overview_polyline.points;
            var line   = PolyUtil.Decode(points);

            ArrayList routeList = new ArrayList();

            foreach (LatLng item in line)
            {
                routeList.Add(item);
            }
            // Draw on map
            PolylineOptions polylineOptions = new PolylineOptions()
                                              .AddAll(routeList)
                                              .InvokeWidth(10)
                                              .InvokeColor(Color.Teal)
                                              .InvokeStartCap(new SquareCap())
                                              .InvokeEndCap(new SquareCap())
                                              .InvokeJointType(JointType.Round)
                                              .Geodesic(true);

            Android.Gms.Maps.Model.Polyline mPolyline = map.AddPolyline(polylineOptions);
        }
        protected override void OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs <Map> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null)
            {
                // Unsubscribe
            }

            if (e.NewElement != null)
            {
                formsMap         = (CommonMap)e.NewElement;
                routeCoordinates = formsMap.RouteCoordinates;
                lastCoordinates  = formsMap.LastCoordinates;
                positionCount    = formsMap.positionCount;
                refreshRoud      = formsMap.refreshRoud;

                if (formsMap.platformRoad.GetType() == typeof(object))
                {
                    formsMap.platformRoad = new PolylineOptions();
                }

                wholeRoad = (PolylineOptions)formsMap.platformRoad;
                Control.GetMapAsync(this);
            }
        }
        private void RoudCreateOptimization()
        {
            NativeMap.Clear();

            if (wholeRoad != null && wholeRoad.Points.Count > 1)
            {
                wholeRoad.InvokeColor(-65535);//red
                wholeRoad.InvokeStartCap(new RoundCap());
                wholeRoad.InvokeEndCap(new RoundCap());

                NativeMap.AddPolyline(wholeRoad);
            }


            if (formsMap.EntirePathObjTmp != null && ((PolylineOptions)formsMap.EntirePathObjTmp).Points.Count > 1)
            {
                PolylineOptions polyline = (PolylineOptions)formsMap.EntirePathObjTmp;
                polyline.InvokeColor(-65535);
                polyline.InvokeStartCap(new RoundCap());
                polyline.InvokeEndCap(new RoundCap());
                NativeMap.AddPolyline(polyline);
            }
            else if (formsMap.EntirePathListTmp != null && formsMap.EntirePathListTmp.Count > 1)
            {
                var polylineOptions = CreatePolyline(formsMap.EntirePathListTmp);
                formsMap.EntirePathObjTmp = polylineOptions;
                NativeMap.AddPolyline(polylineOptions);
            }
        }
Пример #14
0
        protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);

            if (e.PropertyName == "RouteCoordinates" || e.PropertyName == "VisibleRegion")
            {
                CustomMap cMap = (CustomMap)this.Element;
                if (cMap.RouteCoordinates != null)
                {
                    var polylineOptions = new PolylineOptions();
                    polylineOptions.InvokeColor(0x66FF0000);

                    // limpa percurso
                    ((Activity)Forms.Context).RunOnUiThread(() => map.Clear());

                    // adiciona posições do percurso já percorrido
                    foreach (var position in cMap.RouteCoordinates)
                    {
                        polylineOptions.Add(new LatLng(position.Latitude, position.Longitude));
                    }

                    // desenha percurso no mapa
                    ((Activity)Forms.Context).RunOnUiThread(() => map.AddPolyline(polylineOptions));
                }
            }
        }
Пример #15
0
        /// <summary>
        /// Draw main direction line
        /// </summary>
        /// <param name="angle"></param>
        public void DrawDirection(double angle)
        {
            if (is_initialized == false)
            {
                return;
            }

            GlobalCoordinates stop_geo = get_line_position(angle);

            try
            {
                if (MainLine != null)
                {
                    MainLine.Remove();
                    PolylineOptions linePoints = new PolylineOptions();
                    linePoints.Add(ConvertPos(UserPosition));
                    linePoints.Add(ConvertPos(stop_geo));
                    MainLine = googleMap.AddPolyline(linePoints);
                }
                else
                {
                    PolylineOptions linePoints = new PolylineOptions();
                    linePoints.Add(ConvertPos(UserPosition));
                    linePoints.Add(ConvertPos(stop_geo));
                    MainLine = googleMap.AddPolyline(linePoints);
                }
            }
            catch (Exception e)
            {
            }
        }
Пример #16
0
        public void OnMapReady(GoogleMap googleMap)
        {
            map = googleMap;

            if (!isCircle)
            {
                var polylineOptions = new PolylineOptions();
                polylineOptions.InvokeColor(0x66FF0000);

                foreach (var position in routeCoordinates)
                {
                    polylineOptions.Add(new LatLng(position.Latitude, position.Longitude));
                }

                map.AddPolyline(polylineOptions);
            }
            if (isCircle)
            {
                var circleOptions = new CircleOptions();
                circleOptions.InvokeCenter(new LatLng(circle.Position.Latitude, circle.Position.Longitude));
                circleOptions.InvokeRadius(circle.Radius);
                circleOptions.InvokeFillColor(0X00FFFFFF);
                circleOptions.InvokeStrokeColor(0X66FF0000);
                circleOptions.InvokeStrokeWidth(3);
                map.AddCircle(circleOptions);
            }
        }
Пример #17
0
        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");
            }
        }
Пример #18
0
        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);
        }
Пример #19
0
        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);
            }
        }
Пример #20
0
        void FnSetDirectionQuery(string strJSONDirectionResponse)
        {
            var objRoutes = JsonConvert.DeserializeObject <GoogleDirectionClass> (strJSONDirectionResponse);

            //objRoutes.routes.Count  --may be more then one
            if (objRoutes.routes.Count > 0)
            {
                string encodedPoints = objRoutes.routes [0].overview_polyline.points;

                var lstDecodedPoints = FnDecodePolylinePoints(encodedPoints);
                //convert list of location point to array of latlng type
                var latLngPoints = new LatLng[lstDecodedPoints.Count];
                int index        = 0;
                foreach (var loc in lstDecodedPoints)
                {
                    latLngPoints[index++] = loc;                     //new LatLng ( loc.Latitude , loc.Longitude );
                }

                var polylineoption = new PolylineOptions();
                polylineoption.InvokeColor(Android.Graphics.Color.Green);
                polylineoption.Geodesic(true);
                polylineoption.Add(latLngPoints);
                RunOnUiThread(() =>
                              eMap.AddPolyline(polylineoption));
            }
        }
Пример #21
0
        private void DrawTracksButton_Click(object sender, EventArgs e)
        {
            var points = journeyPointRespository.GetTrackPointsForJourney(SelectedJourneyId);

            LatLngBounds.Builder builder = new LatLngBounds.Builder();
            PolylineOptions      line    = new PolylineOptions().InvokeColor(Color.Purple);


            if (points.Count() > 0)
            {
                MarkerOptions moStart = new MarkerOptions();
                moStart.SetPosition(new LatLng(points.ElementAt(0).Lat, points.ElementAt(0).Lon));
                moStart.SetIcon((BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueGreen)));

                foreach (var v in points)
                {
                    LatLng l = new LatLng(v.Lat, v.Lon);
                    builder.Include(l);
                    line.Add(l);
                }

                MarkerOptions moEnd = new MarkerOptions();
                moEnd.SetPosition(new LatLng(points.ElementAt(points.Count() - 1).Lat, points.ElementAt(points.Count() - 1).Lon));
                moEnd.SetIcon((BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueRed)));

                _map.AddPolyline(line);
                _map.AddMarker(moStart);
                _map.AddMarker(moEnd);
                _map.MoveCamera(CameraUpdateFactory.NewLatLngBounds(builder.Build(), 80));
            }
        }
Пример #22
0
        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);
            }
        }
Пример #23
0
        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);
        }
        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);
            }));
        }
Пример #25
0
        private async void GetRutas(int id_mandado)
        {
            List <Manboss_mandados_ruta> rutas = await core.GetRutas(id_mandado);

            LatLngBounds.Builder builder = new LatLngBounds.Builder();
            foreach (Manboss_mandados_ruta ruta in rutas)
            {
                markerOpt1 = new MarkerOptions();
                LatLng lugar = new LatLng(ruta.Latitud, ruta.Longitud);
                builder.Include(lugar);
                markerOpt1.SetPosition(lugar);
                markerOpt1.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.mandado));
                _map.AddMarker(markerOpt1);
            }
            //Mover camera
            LatLngBounds bounds       = builder.Build();
            CameraUpdate cameraUpdate = CameraUpdateFactory.NewLatLngBounds(bounds, 300);

            _map.MoveCamera(cameraUpdate);
            //Dibujar ruta
            List <Manboss_repartidores_ubicaciones> ubicaciones = await core.GetUbicaciones(id_mandado);

            var polylineOptions = new PolylineOptions();

            polylineOptions.InvokeColor(0x6604B7FF);
            foreach (var position in rutas)
            {
                polylineOptions.Add(new LatLng(position.Latitud, position.Longitud));
            }
            foreach (var position in ubicaciones)
            {
                polylineOptions.Add(new LatLng(position.latitud, position.longitud));
            }
            _map.AddPolyline(polylineOptions);
        }
Пример #26
0
        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);
        }
Пример #27
0
        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);
            }
        }
Пример #28
0
        private void ShowTheWay()
        {
            PolylineOptions polylineOptions = new PolylineOptions();
            LatLngBounds    bounds;

            LatLng[] points = location.getPath(sourceMarkerOptions.Position, destinationMarkerOptions.Position, out bounds);
            polylineOptions.Add(points);
            googleMap.AddPolyline(polylineOptions);

            var filteredSites = location.allSites.Where(x => bounds.Contains(x.Item1));


            googleMap.AnimateCamera(CameraUpdateFactory.NewLatLngBounds(bounds, 60), 2000, null);


            inputManager.HideSoftInputFromWindow(this.CurrentFocus.WindowToken, HideSoftInputFlags.None);

            foreach (var site in filteredSites)
            {
                var markerOp = new MarkerOptions();
                markerOp.SetPosition(site.Item1);
                markerOp.SetTitle(site.Item2);
                googleMap.AddMarker(markerOp);
            }
        }
Пример #29
0
        public void DrawRouteToPlace(Route route, Place place)
        {
            if (MyLocation == null)
            {
                return;
            }

            map.Clear();

            string snippet = route.legs[0].distance.text +
                             ", " + route.legs[0].duration.text;

            var marker = new MarkerOptions();

            marker.SetTitle(place.name);
            marker.SetSnippet(snippet);
            marker.SetPosition(new LatLng(place.geometry.location.lat, place.geometry.location.lng));
            map.AddMarker(marker);

            var polyline = new PolylineOptions();

            polyline.InvokeColor(ContextCompat.GetColor(Activity.ApplicationContext, Resource.Color.route_polyline));
            var points = RouteHelper.GetPointsFromRoute(route);

            foreach (var point in points)
            {
                polyline.Add(new LatLng(point.lat, point.lng));
            }

            map.AddPolyline(polyline);

            UpdateCameraPosition(new LatLng(MyLocation.lat, MyLocation.lng));
        }
 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);
         }
     }
 }
Пример #31
0
        // 만들어진 폴리라인을 가지고 선형을 만들어주는 메소드 선형뿐만아니라 그리드 뷰까지 찍어줌
        public Alignment CreateAlign(Polyline guid)
        {
            Document dc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; // 현재 도큐먼트를 가져옴
            Database db = dc.Database; // 현재 데이터베이스를 가져옴

            CivilDocument doc = CivilApplication.ActiveDocument;
            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            using (Transaction acTrans = db.TransactionManager.StartTransaction())
            {
                BlockTable acBlktbl = acTrans.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable; // 선을 그리기 위한 블럭테이블 생성
                BlockTableRecord acblkTblrec = acTrans.GetObject(acBlktbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; // 어디 도면에 그릴지 선택

                PolylineOptions plops = new PolylineOptions(); // 폴리라인 옵션 지정

                plops.AddCurvesBetweenTangents = true;
                plops.EraseExistingEntities = true;
                plops.PlineId = guid.ObjectId;

                ObjectId testAlignmentID = Alignment.Create(doc, plops, "내가만든 선형", null, "0", "Proposed", "All Labels");

                Alignment oAlignment = acTrans.GetObject(testAlignmentID, OpenMode.ForRead) as Alignment;

                ObjectId layerId = oAlignment.LayerId;
                // get first surface in the document
                ObjectId surfaceId = doc.GetSurfaceIds()[0];
                // get first style in the document
                ObjectId styleId = doc.Styles.ProfileStyles[0];
                // get the first label set style in the document
                ObjectId labelSetId = doc.Styles.LabelSetStyles.ProfileLabelSetStyles[0];

                try
                {
                    ObjectId profileId = Profile.CreateFromSurface("My Profile", testAlignmentID, surfaceId, layerId, styleId, labelSetId);

                }
                catch (Autodesk.AutoCAD.Runtime.Exception e)
                {
                    ed.WriteMessage(e.Message);
                }

                PromptPointResult pPtRes;
                PromptPointOptions pPtOpts = new PromptPointOptions("종단뷰를 그릴 위치를 찍어주세요~");
                pPtRes = dc.Editor.GetPoint(pPtOpts);
                Point3d ptStart = pPtRes.Value;
                if (pPtRes.Status == PromptStatus.Cancel) return null;

                // ObjectId ProfileViewId = ProfileView.Create(alignID, ptStart);
                ObjectId pfrVBSStyleId = doc.Styles.ProfileViewBandSetStyles[8];

                ObjectId ProfileViewId2 = ProfileView.Create(doc, "My Profile", pfrVBSStyleId, testAlignmentID, ptStart);
                //doc, "My Profile View", pfrVBSStyleId, alignID, ptInsert
                acTrans.Commit();
                return oAlignment;
            }
        }
Пример #32
0
 public Polyline AddPolyline(PolylineOptions options)
 {
     return new Polyline (InternalAddPolyline (options));
 }