示例#1
0
        protected override void OnMapReady(Android.Gms.Maps.GoogleMap map)
        {
            base.OnMapReady(map);

            clearRoute();

            var polylineOptions = new PolylineOptions();

            polylineOptions.InvokeColor(0x66FF0000);

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

            lines.Add(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);
        }
示例#3
0
        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);
        }
        // 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);
        }
示例#6
0
        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));
        }
示例#8
0
        //TODO Clean up that mess :)
        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);

            var customMap = (CustomMap)sender;

            if (e.PropertyName == CustomMap.ActualPositionProperty.PropertyName)
            {
                if (_lastPosition == null)
                {
                    _lastPosition = customMap.ActuallPosition;
                    return;
                }

                var actuallPosition = customMap.ActuallPosition;

                var po = new PolylineOptions();
                po.InvokeColor(0x66FF0000);
                po.InvokeWidth(5);
                po.Add(new LatLng(_lastPosition.Latitude, _lastPosition.Longitude));
                po.Add(new LatLng(actuallPosition.Latitude, actuallPosition.Longitude));

                var polyline = _map.AddPolyline(po);
                _mapPolylines.Add(polyline);

                _lastPosition = actuallPosition;
            }

            if (e.PropertyName == CustomMap.PositionsProperty.PropertyName)
            {
                positions.Clear();

                foreach (var position in customMap.Positions)
                {
                    positions.Add(new LatLng(position.Latitude, position.Longitude));
                }

                if (_map == null)
                {
                    return;
                }
                UpdatePolylines();
            }
        }
        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;
        }
示例#10
0
        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);
        }
示例#11
0
        private void AddPolyline(Polyline polyline)
        {
            PolylineOptions options = new PolylineOptions();

            options.Add(polyline.Points.Select(p => new LatLng(p.Latitude, p.Longitude)).ToArray());
            if (polyline.ZIndex.HasValue)
            {
                options.InvokeZIndex(polyline.ZIndex.Value);
            }
            if (polyline.StrokeColor != null)
            {
                options.InvokeColor(Graphics.Color.ParseColor(polyline.StrokeColor));
            }
            if (polyline.StrokeWidth.HasValue)
            {
                options.InvokeWidth(polyline.StrokeWidth.Value);
            }
            googleMap.AddPolyline(options);
        }
        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;
            }
        }
示例#13
0
        private void UpdatePolyline()
        {
            if (polyline != null)
            {
                polyline.Remove();
                polyline.Dispose();
            }
            var polilyneOptions = new PolylineOptions();

            polilyneOptions.InvokeColor(Android.Graphics.Color.Red);
            var coordenadas = ((MapCustomRender)this.Element).CoordenadasRota;

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

            polyline = map.AddPolyline(polilyneOptions);
        }
        private void UpdatePolyLine()
        {
            if (polyline != null)
            {
                polyline.Remove();
                polyline.Dispose();
            }

            var polylineOptions = new PolylineOptions();

            polylineOptions.InvokeColor(0x66FF0000);

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

            NativeMap.AddPolyline(polylineOptions);
        }
示例#15
0
        private void MostrarPontosNoMapa(JObject estacionamento, JArray lista)
        {
            foreach (var ponto in lista)
            {
                var           latitude  = (ponto["Localizacao"])["Latitude"].Value <double>();
                var           longitude = (ponto["Localizacao"])["Longitude"].Value <double>();
                var           altitude  = (ponto["Localizacao"])["Altitude"].Value <double>();
                LatLng        latlng    = new LatLng(Convert.ToDouble(latitude), Convert.ToDouble(longitude));
                MarkerOptions options   = new MarkerOptions().SetPosition(latlng).SetTitle(ponto["Id"].Value <long>().ToString()).SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.dot));
                Marker        marker    = GMap.AddMarker(options);
                var           vagas     = (JArray)ponto["VagasConectadas"];
                Marcador      marcador  = new Marcador(estacionamento, marker)

                {
                    Id = ponto["Id"].Value <long>()
                };

                foreach (var conexao in ponto["Conexoes"])
                {
                    foreach (var _ponto in lista)
                    {
                        if (_ponto["Id"].Value <long>() == conexao.Value <long>())
                        {
                            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(latlng, new LatLng(_latitude, _longitude));
                            opt = opt.InvokeWidth(5);
                            opt = opt.InvokeColor(Color.Red);

                            Polyline line = GMap.AddPolyline(opt);
                            marcador.Linhas.Add(line);
                        }
                    }
                }
                MarcadoresColocados.Add(marcador);


                MostrarVagasNoMapa((JObject)ponto, vagas);
            }
        }
示例#16
0
        private async void GoPlanButtonClickedAsync()
        {
            goPlan.Visibility        = ViewStates.Invisible;
            goStation.Visibility     = ViewStates.Invisible;
            goDestination.Visibility = ViewStates.Invisible;
            goNavigate.Visibility    = ViewStates.Invisible;
            plan    = true;
            nearest = false;

            string url = "https://maps.googleapis.com/maps/api/directions/json?origin="
                         + startLat + "," + startLng + "&destination=" + destinationLat + "," + destinationLng + "&key=AIzaSyBeT4UxwuGgyndiaiagBgY-thD09SvOEGE";

            string json = await FetchGoogleDataAsync(url);

            Log.Error("lv", json);
            DirectionsDto directions = JsonConvert.DeserializeObject <DirectionsDto>(json);

            var lstDecodedPoints = FnDecodePolylinePoints(directions.routes[0].overview_polyline.points);
            var latLngPoints     = new LatLng[lstDecodedPoints.Count];
            int index            = 0;

            foreach (Android.Locations.Location loc in lstDecodedPoints)
            {
                latLngPoints[index++] = new LatLng(loc.Latitude, loc.Longitude);
            }
            // Create polyline
            PolylineOptions polylineoption = new PolylineOptions();

            polylineoption.InvokeColor(Android.Graphics.Color.Green);
            polylineoption.Geodesic(true);
            polylineoption.Add(latLngPoints);
            isThereAPoli = true;

            // Add polyline to map
            this.RunOnUiThread(() =>
                               GMap.AddPolyline(polylineoption));
            CameraUpdate camera = CameraUpdateFactory.NewLatLngZoom(MidPoint(Convert.ToDouble(startLat), Convert.ToDouble(startLng), x, y), 8);

            GMap.MoveCamera(camera);

            goNavigate.Visibility = ViewStates.Visible;
        }
示例#17
0
        private void UpdatePolylines()
        {
            //TODO add here posibility to bind custom polylines in order to view historical activities
            foreach (var polyline in _mapPolylines)
            {
                polyline.Remove();
            }
            _mapPolylines.Clear();

            var newPo = new PolylineOptions();

            newPo.InvokeColor(0x66FF0000);
            newPo.InvokeWidth(5);
            foreach (var position in positions)
            {
                newPo.Add(new LatLng(position.Latitude, position.Longitude));
            }

            _map.AddPolyline(newPo);
        }
示例#18
0
        private void UpdatePolyLine()
        {
            if (polyline != null)
            {
                polyline.Remove();
                polyline.Dispose();
            }

            var polylineOptions = new PolylineOptions();

            polylineOptions.InvokeColor(0x660066ff);
            polylineOptions.InvokeWidth(25);

            foreach (var position in ((CustomMap)this.Element).RouteCoordinates)
            {
                polylineOptions.Add(new LatLng(position.Latitude, position.Longitude));
            }

            polyline = map.AddPolyline(polylineOptions);
        }
示例#19
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            shouldExecuteOnResume = false;

            base.OnCreate(savedInstanceState);

            View acquaintanceDetailLayout = LayoutInflater.Inflate(Resource.Layout.AcquaintanceDetail, null);

            SetContentView(acquaintanceDetailLayout);
            toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);

            // ensure that the system bar color gets drawn
            Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);

            // enable the back button in the action bar
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);

            // extract the acquaintance id fomr the intent
            IdEmpleado    = Intent.GetIntExtra(GetString(Resource.String.acquaintanceDetailIntentKey), 0);
            vengoConsulta = Intent.GetBooleanExtra(GetString(Resource.String.ConsultaIntentKey), false);

            empleado = HelperMethods.getUserById(IdEmpleado);
            nombreCompletoEmpleado = HelperMethods.DisplayName(empleado);

            // set the activity title and action bar title
            Title = SupportActionBar.Title = nombreCompletoEmpleado;

            SetupViews(acquaintanceDetailLayout, savedInstanceState);

            HelperMethods.SetupAnimations(this);

            mPolylineOptions = new PolylineOptions();
            mPolylineOptions.InvokeColor(Color.Blue).InvokeWidth(10);

            //Should call this to let the map showing
            shouldExecuteOnResume = true;
            Instance = this;
            OnResume();
        }
        void UpdateMap(TripPoint point, bool updateCamera = true)
        {
            if (map == null)
            {
                return;
            }
            //Get trail position or current potion to move car
            var latlng = point == null
                ? viewModel?.CurrentPosition?.ToLatLng()
                : point.ToLatLng();

            Activity?.RunOnUiThread(() =>
            {
                UpdateCar(latlng);
                driveLine?.Remove();
                var polyOptions = new PolylineOptions();

                if (allPoints == null)
                {
                    allPoints = viewModel.CurrentTrip.Points.ToLatLngs();
                }
                else if (point != null)
                {
                    allPoints.Add(point.ToLatLng());
                }

                polyOptions.Add(allPoints.ToArray());

                if (!driveLineColor.HasValue)
                {
                    driveLineColor = new Color(ContextCompat.GetColor(Activity, Resource.Color.recording_accent));
                }

                polyOptions.InvokeColor(driveLineColor.Value);
                driveLine = map.AddPolyline(polyOptions);
                if (updateCamera)
                {
                    UpdateCamera(latlng);
                }
            });
        }
示例#21
0
        private void BtnTerrain_Click(object sender, EventArgs e)
        {
            string url = "https://maps.googleapis.com/maps/api/directions/json?origin="
                         + options.Position.Latitude.ToString() + "," + options.Position.Longitude.ToString() +
                         "&destination=" + latlngCetys.Latitude.ToString() + "," + latlngCetys.Longitude.ToString() +
                         "&key=" + key;
            //"https://maps.googleapis.com/maps/api/directions/json?origin=32.477443576,-117.025249343&destination=32.5066012314124,-116.924396641552&key=AIzaSyCq7XqwYUeGOVLqs4FzvjDrYYRGLEar3-A"
            //string url = "https://maps.googleapis.com/maps/api/directions/json?origin=Chicago,IL&destination=Los+Angeles,CA&waypoints=Joplin,MO|Oklahoma+City,OK&key=AIzaSyCq7XqwYUeGOVLqs4FzvjDrYYRGLEar3-A";
            var             client   = new WebClient();
            var             content  = client.DownloadString(url);
            dynamic         route    = JObject.Parse(content);
            List <Location> locList  = DecodePolylinePoints("affeEjogiU]fAc@rAgBlFq@lBEV?LJf@`@hBlAzG}@n@OPa@FuANb@jK?NkAH{Gf@YtEUdCOZYRm@Z_@f@Qf@Y|BEb@bEr@lF`ATAVB~AXjBr@`@RHQ`CcEt@iAl@i@j@w@rBqDjDyF~DaGpBsCbAaBvCqEnEyG~A}B|BoDzBkDfA}BtBgFt@iBd@qA^uAPeAXoDd@cGLkCCo@O}@iAsDSk@y@eCmAkDUy@U}A]wD_@_FIw@a@wBMe@[_Am@aAk@{@iAgAkAw@m@YqDeAuAe@q@[iBwAu@_Ac@u@a@{@k@{AWcASaAUiBO{B@kCLqBN{AVkA|@}ChBmGx@uCTwA@e@?w@Eq@Kw@Om@Uk@Sc@gA_BqFqI}@eBuAyBk@}@wAoBgHiKiIwL_A{A_AmBmAgC_CyFaAiBy@kAm@k@aBqAgC_BoE{CeCiBiB{AyBkB{KwJwBkBs@w@_AsAm@cAgAwD_AkDeB_Gw@aD[oA]uB]sAYgBg@uCc@gBm@{A]m@q@u@g@_@oEuDeDyC{CsCqFcEs@w@}@q@mFeDmB{Aa@YsA_A}EwDiNgK{AoAqHqFgBiAsF{DwAo@{@QkAIo@Aq@B{Dt@{Ez@uEt@uCd@cCh@y@Pm@iAmAyBi@o@MSI]EYMQBs@z@kXXoIHeANmBTyA\\iAb@}@lAaB~@eAhB{BfA}A`@y@t@yBXaBZaCtA{NRqCJwBBgBCiBGkAIu@k@_CuEuOiGkQgA}Du@qDo@yDqA{LCiANwCFeB?gAGwAMuADWAYGq@Mk@eBqFUw@Km@AU?OFYDIHIx@a@\\MzB{@nC{@vDsA`EyA`Dw@vHkArB[bC]^Fv@?vCSPC?\\NlBFp@AHg@d@KP@ZJv@");
            PolylineOptions pOptions = new PolylineOptions();

            foreach (Location l in locList)
            {
                pOptions.Add(new LatLng(l.Latitude, l.Longitude));
            }
            pOptions.InvokeColor(-65536);
            Polyline poly = map.AddPolyline(pOptions);
        }
示例#22
0
        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));

                var markerOptions = new MarkerOptions();
                markerOptions.SetPosition(new LatLng(position.Latitude, position.Longitude));
                markerOptions.SetTitle(position.Label);
                markerOptions.SetSnippet(position.Address);
                map.AddMarker(markerOptions);
            }

            NativeMap.AddPolyline(polylineOptions);
        }
 private void createLines()
 {
     try
     {
         var formsMap       = (ExtendedMap)Element;
         var androidMapView = (Android.Gms.Maps.MapView)Control;
         //androidMapView.Map.Clear();
         PolylineOptions line = new PolylineOptions();
         line.InvokeColor(global::Android.Graphics.Color.Blue);
         foreach (var item in formsMap.polilenes)
         {
             LatLng pos = new LatLng(item.Latitude, item.Longitude);
             line.Add(pos);
         }
         androidMapView.Map.AddPolyline(line);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
示例#24
0
        private void ShowOnMap()
        {
            var polylineoption = new PolylineOptions();

            polylineoption.InvokeColor(Color.ParseColor("#509BFC"));
            polylineoption.Geodesic(true);

            List <Position> route = CalculateRoute.GetPositions(Assets);

            foreach (var pos in route)
            {
                polylineoption.Add(new LatLng(pos.Latitude, pos.Longitude));
            }

            var    index   = Convert.ToInt32((route.IndexOf(route.FirstOrDefault()) + route.IndexOf(route.LastOrDefault())) / 2);
            LatLng lastpos = new LatLng(route[index].Latitude, route[index].Longitude);

            mMap.AddPolyline(polylineoption);

            UpdateCameraPosition(lastpos);
        }
        //This function initilize the Map
        public void fnInitiateMapAsync()
        {
            if (map != null)
            {
                ShowLoading();
                map.MapType = GoogleMap.MapTypeSatellite;                          //select the map type
                CameraPosition.Builder builder = CameraPosition.InvokeBuilder();
                builder.Target(new LatLng(position.Latitude, position.Longitude)); //Target to some location hardcoded
                builder.Zoom(18);                                                  //Zoom multiplier
                builder.Bearing(45);                                               //bearing is the compass measurement clockwise from North
                builder.Tilt(90);                                                  //tilt is the viewing angle from vertical
                CameraPosition cameraPosition = builder.Build();
                CameraUpdate   cameraUpdate   = CameraUpdateFactory.NewCameraPosition(cameraPosition);
                LatLng         latLng         = new LatLng(position.Latitude, position.Longitude);
                map.AnimateCamera(CameraUpdateFactory.NewLatLngZoom(latLng, 17));
                map.MyLocationEnabled = true;
                map.MapType           = GoogleMap.MapTypeNormal;

                Worker       pclClass = SharedObjects.pcl;
                List <Route> routes   = SharedObjects.routes;

                timeTxV.Text = "Temps: " + routes[0].legs[0].duration.text;

                string encodedPoints    = 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 (Position loc in lstDecodedPoints)
                {
                    latLngPoints[index++] = new LatLng(loc.Latitude, loc.Longitude);
                }
                var polylineoption = new PolylineOptions();
                polylineoption.InvokeColor(Android.Graphics.Color.Red);
                polylineoption.Geodesic(true);
                polylineoption.Add(latLngPoints);
                map.AddPolyline(polylineoption);
                DismissLoading();
            }
        }
示例#26
0
 private void SetupMapIfNeeded()
 {
     if (_map == null)
     {
         _map = _mapFragment.Map;
         if (_map != null)
         {
             var centerPoint = new LatLng(Station.TroncalRouteCenter.Y, Station.TroncalRouteCenter.X);
             Activity.RunOnUiThread(delegate {
                 _map.AnimateCamera(CameraUpdateFactory.NewLatLngZoom(centerPoint, 15.0f));
                 _map.MyLocationEnabled = true;
             });
             stations = stationRepository.Stations;
             Activity.RunOnUiThread(delegate {
                 foreach (var station in stations)
                 {
                     var location              = new LatLng(station.Latitude, station.Longitude);
                     var stationImageId        = Resources.GetIdentifier(station.ImageFilename().ToLower(), "drawable", Activity.PackageName);
                     var originalStationBitmap = BitmapFactory.DecodeResource(Resources, stationImageId);
                     var scale                   = Resources.DisplayMetrics.Density;
                     var pixels                  = 35;
                     var stationBitmap           = Bitmap.CreateScaledBitmap(originalStationBitmap, (int)(pixels * scale + 0.5f), (int)(pixels * scale + 0.5f), false);
                     MarkerOptions markerOptions = new MarkerOptions()
                                                   .SetPosition(location)
                                                   .InvokeIcon(BitmapDescriptorFactory.FromBitmap(stationBitmap))
                                                   .SetTitle(station.Name);
                     _map.AddMarker(markerOptions);
                 }
                 var polylineOptions = new PolylineOptions();
                 polylineOptions.InvokeWidth(5.0f);
                 polylineOptions.InvokeColor(Color.Black);
                 foreach (var point in Station.TroncalRoutePath)
                 {
                     polylineOptions.Add(new LatLng(point.Y, point.X));
                 }
                 _map.AddPolyline(polylineOptions);
             });
         }
     }
 }
        private void AddLine(LatLng location1, LatLng location2, Color color)
        {
            try
            {
                PolylineOptions p = new PolylineOptions();
                p.Add(location1, location2);
                p.InvokeWidth(3 * pixelDensity);
                p.InvokeJointType(JointType.Bevel);
                p.InvokeColor(Color.Black);
                thisMap.AddPolyline(p);

                p = new PolylineOptions();
                p.Add(location1, location2);
                p.InvokeWidth(2 * pixelDensity);
                p.InvokeJointType(JointType.Bevel);
                p.InvokeColor(color);
                thisMap.AddPolyline(p);
            }
            catch
            {
            }
        }
示例#28
0
        /// <summary>
        /// Draw the polyline from the PolylineCoordinates.
        /// </summary>
        private void UpdatePolyLine()
        {
            if (map != null && ((CustomMap)this.Element).PolylineCoordinates != null)
            {
                if (polyline != null)
                {
                    polyline.Remove();
                    polyline.Dispose();
                }
                var polylineOptions = new PolylineOptions();

                polylineOptions.InvokeColor(((CustomMap)this.Element).PolylineColor.ToAndroid());
                polylineOptions.InvokeWidth((float)((CustomMap)this.Element).PolylineThickness);

                foreach (var position in ((CustomMap)this.Element).PolylineCoordinates)
                {
                    polylineOptions.Add(new LatLng(position.Latitude, position.Longitude));
                }

                polyline = map.AddPolyline(polylineOptions);
            }
        }
示例#29
0
        protected override void OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs <Map> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement == null)
            {
                mapView = Control as MapView;
                map     = mapView.Map;
                myMap   = e.NewElement as MyMap;
                PolylineOptions line = new PolylineOptions();
                line.InvokeColor(global::Android.Graphics.Color.Red);
                // Add the points of the polyline
                LatLng latLng = new LatLng(37, -122);
                line.Add(latLng);
                //latLng = new LatLng(37, -122.001);
                //line.Add(latLng);
                latLng = new LatLng(37.001, -122.002);
                line.Add(latLng);
                // Add the polyline to the map
                map.AddPolyline(line);
            }
        }
示例#30
0
        /// <summary>
        /// Adds a route to the map
        /// </summary>
        /// <param name="line">The route to add</param>
        private void AddLine(TKPolyline line)
        {
            line.PropertyChanged += OnLinePropertyChanged;

            var polylineOptions = new PolylineOptions();

            if (line.Color != Color.Default)
            {
                polylineOptions.InvokeColor(line.Color.ToAndroid().ToArgb());
            }
            if (line.LineWidth > 0)
            {
                polylineOptions.InvokeWidth(line.LineWidth);
            }

            if (line.LineCoordinates != null)
            {
                polylineOptions.Add(line.LineCoordinates.Select(i => i.ToLatLng()).ToArray());
            }

            this._polylines.Add(line, this._googleMap.AddPolyline(polylineOptions));
        }