示例#1
0
 public void Draw(IEnumerable <LatLng> Positions, float Hue, object Metadata = null)
 {
     foreach (var p in Positions)
     {
         Draw(p, BitmapDescriptorFactory.DefaultMarker(Hue), Metadata);
     }
 }
        private async void OnGetDetails(object sender, GoogleMap.MapClickEventArgs e)
        {
            Geocoder geocoder = new Geocoder(this);
            var      results  = await geocoder.GetFromLocationAsync(e.Point.Latitude, e.Point.Longitude, 1);

            if (results.Count > 0)
            {
                var result = results[0];
                if (lastGeoMarker == null)
                {
                    MarkerOptions markerOptios = new MarkerOptions()
                                                 .SetPosition(new LatLng(result.Latitude, result.Longitude))
                                                 .SetTitle(result.FeatureName)
                                                 .SetSnippet(GetAdress(result))
                                                 .SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueOrange));
                    lastGeoMarker = map.AddMarker(markerOptios);
                }
                else
                {
                    lastGeoMarker.Position = new LatLng(result.Latitude, result.Longitude);
                    lastGeoMarker.Title    = result.FeatureName;
                    lastGeoMarker.Snippet  = GetAdress(result);
                }
                lastGeoMarker.ShowInfoWindow();
            }
        }
        private async void ShowPOI(object sender, GoogleMap.MapLongClickEventArgs e)
        {
            foreach (var point in pointsOfInterest)
            {
                point.Remove();
            }
            pointsOfInterest.Clear();

            LatLngBounds bounds = e.Point.GetBoundingBox(8000);

            var geocoder = new Geocoder(this);
            var results  = await geocoder.GetFromLocationNameAsync("Starbucks", 5,
                                                                   bounds.Southwest.Latitude, bounds.Southwest.Longitude,
                                                                   bounds.Northeast.Latitude, bounds.Northeast.Longitude);

            foreach (var result in results)
            {
                var markerOptions = new MarkerOptions()
                                    .SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueCyan))
                                    .SetPosition(new LatLng(result.Latitude, result.Longitude))
                                    .SetTitle(result.FeatureName)
                                    .SetSnippet(GetAdress(result));

                pointsOfInterest.Add(map.AddMarker(markerOptions));
            }
        }
        public async Task <bool> showMarkerOnMap()
        {
            var issueList = await FetchPostList();

            foreach (var issue in issueList)
            {
                MarkerOptions mOptions = new MarkerOptions();

                mOptions.SetPosition(issue.GetLocation());
                if (issue.Issueflag == "green")
                {
                    mOptions.SetTitle(issue.IssueType + ": No Blockage");
                    mOptions.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueGreen));
                    googleMap.AddMarker(mOptions);
                }
                else if (issue.Issueflag == "yellow")
                {
                    mOptions.SetTitle(issue.IssueType + ": Partial Blockage");
                    mOptions.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueYellow));
                    googleMap.AddMarker(mOptions);
                }
                else if (issue.Issueflag == "red")
                {
                    mOptions.SetTitle(issue.IssueType + ": Full Blockage");
                    mOptions.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueRed));
                    googleMap.AddMarker(mOptions);
                }
            }
            return(true);
        }
示例#5
0
        void LoadPoints()
        {
            var points = new List <Tuple <string, double, double> > ()
            {
                Tuple.Create("London", 51.50000, -0.11670),
                Tuple.Create("New York", 40.75170, -73.99420),
                Tuple.Create("Hong Kong", 21.75000, 115.00000),
                Tuple.Create("Berlin", 52.51670, 13.33330),
                Tuple.Create("Buenos Aires", -34.33320, -58.49990),
                Tuple.Create("Cairo, Egypt", 30.00000, 31.28330),
                Tuple.Create("Geneva", 46.23330, 6.06670),
                Tuple.Create("Singapore", 1.36670, 103.75000),
                Tuple.Create("Washington", 38.89750, -77.00920),
                Tuple.Create("Canberra", -35.35000, 149.16670)
            };

            var fiveRandomPointsFromList = points.OrderBy(x => Guid.NewGuid()).Take(5);

            if (map != null)
            {
                RunOnUiThread(new Action(delegate { map.Clear(); }));

                foreach (var point in fiveRandomPointsFromList)
                {
                    var markerOpt1 = new MarkerOptions()
                                     .SetTitle(point.Item1)
                                     .SetPosition(new LatLng(point.Item2, point.Item3))
                                     .InvokeIcon(BitmapDescriptorFactory.DefaultMarker(
                                                     BitmapDescriptorFactory.HueMagenta));
                    RunOnUiThread(new Action(delegate { map.AddMarker(markerOpt1); }));
                }
            }
        }
示例#6
0
        void addMarkers()
        {
            map.AddMarker(new MarkerOptions()
                          .SetPosition(BRISBANE)
                          .SetTitle("Brisbane"));

            map.AddMarker(new MarkerOptions()
                          .SetPosition(MELBOURNE)
                          .SetTitle("Melbourne")
                          .SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueAzure)));

            map.AddMarker(new MarkerOptions()
                          .SetPosition(SYDNEY)
                          .SetTitle("Sydney")
                          .SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueRed)));

            map.AddMarker(new MarkerOptions()
                          .SetPosition(ADELAIDE)
                          .SetTitle("Adelaide")
                          .SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueYellow)));

            map.AddMarker(new MarkerOptions()
                          .SetPosition(PERTH)
                          .SetTitle("Perth")
                          .SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueMagenta)));
        }
示例#7
0
 public BitmapDescriptor PinImageDispatcher(int LIncidentType)
 {
     if (LIncidentType == 0)
     {
         if (Device.RuntimePlatform.Equals(Device.iOS))
         {
             return(BitmapDescriptorFactory.FromBundle("ViolencePin"));
         }
         else if (Device.RuntimePlatform.Equals(Device.Android))
         {
             return(BitmapDescriptorFactory.FromBundle("ViolencePin.png"));
         }
     }
     else if (LIncidentType == 1)
     {
         if (Device.RuntimePlatform.Equals(Device.iOS))
         {
             return(BitmapDescriptorFactory.FromBundle("DisasterPin"));
         }
         else if (Device.RuntimePlatform.Equals(Device.Android))
         {
             return(BitmapDescriptorFactory.FromBundle("DisasterPinBlue.png"));
         }
     }
     else if (LIncidentType == 2)
     {
         if (Device.RuntimePlatform.Equals(Device.iOS))
         {
             return(BitmapDescriptorFactory.FromBundle("EventPin"));
         }
         else if (Device.RuntimePlatform.Equals(Device.Android))
         {
             return(BitmapDescriptorFactory.FromBundle("EventPin.png"));
         }
     }
     else if (LIncidentType == 3)
     {
         if (Device.RuntimePlatform.Equals(Device.iOS))
         {
             return(BitmapDescriptorFactory.FromBundle("TrafficPin"));
         }
         else if (Device.RuntimePlatform.Equals(Device.Android))
         {
             return(BitmapDescriptorFactory.FromBundle("TrafficPin.png"));
         }
     }
     else if (LIncidentType == 4)
     {
         if (Device.RuntimePlatform.Equals(Device.iOS))
         {
             return(BitmapDescriptorFactory.FromBundle("EnvironmentPin"));
         }
         else if (Device.RuntimePlatform.Equals(Device.Android))
         {
             return(BitmapDescriptorFactory.FromBundle("EnvironmentPin.png"));
         }
     }
     return(BitmapDescriptorFactory.DefaultMarker(Color.White));
 }
示例#8
0
        public BitmapDescriptor GetMarkerIcon(Android.Graphics.Color color)
        {
            float[] hsv = new float[3];

            Android.Graphics.Color.ColorToHSV(color, hsv);

            return(BitmapDescriptorFactory.DefaultMarker(hsv[0]));
        }
示例#9
0
        public void DrawTripOnMap(string json)
        {
            Android.Gms.Maps.Model.Polyline mPolyline;
            Marker pickupMarker;

            var directionData = JsonConvert.DeserializeObject <DirectionParser>(json);

            var    pointCode  = directionData.routes[0].overview_polyline.points;
            var    line       = PolyUtil.Decode(pointCode);
            LatLng firstpoint = line[0];
            LatLng lastpoint  = line[line.Count - 1];

            //My take off position
            MarkerOptions markerOptions = new MarkerOptions();

            markerOptions.SetPosition(firstpoint);
            markerOptions.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueRed));
            pickupMarker = mainMap.AddMarker(markerOptions);

            //Constanly Changing Current Location;
            MarkerOptions positionMarkerOption = new MarkerOptions();

            positionMarkerOption.SetPosition(firstpoint);
            positionMarkerOption.SetTitle("Current Location");
            positionMarkerOption.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.position));
            positionMarker = mainMap.AddMarker(positionMarkerOption);

            MarkerOptions markerOptions1 = new MarkerOptions();

            markerOptions1.SetPosition(lastpoint);
            markerOptions1.SetTitle("Pickup Location");
            markerOptions1.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueGreen));
            destinationMarker = mainMap.AddMarker(markerOptions1);

            ArrayList routeList     = new ArrayList();
            int       locationCount = 0;

            foreach (LatLng item in line)
            {
                routeList.Add(item);
                locationCount++;
                Console.WriteLine("Position" + locationCount.ToString() + "=" + item.Latitude.ToString() + "," + item.Longitude.ToString());
            }

            PolylineOptions polylineOptions = new PolylineOptions()
                                              .AddAll(routeList)
                                              .InvokeWidth(20)
                                              .InvokeColor(Color.Teal)
                                              .InvokeStartCap(new SquareCap())
                                              .InvokeEndCap(new SquareCap())
                                              .InvokeJointType(JointType.Round)
                                              .Geodesic(true);

            mPolyline = mainMap.AddPolyline(polylineOptions);
            mainMap.UiSettings.ZoomControlsEnabled = true;
            mainMap.AnimateCamera(CameraUpdateFactory.NewLatLngZoom(firstpoint, 15));
            destinationMarker.ShowInfoWindow();
        }
示例#10
0
        public void OnMapReady(GoogleMap map)
        {
            _map = map;

            if (_map != null)
            {
                _map.MapType = GoogleMap.MapTypeNormal;
                _map.UiSettings.CompassEnabled = true;

                MarkerOptions markerOpt1 = new MarkerOptions();
                markerOpt1.SetPosition(new LatLng(-19.9019194, -43.9462491));
                markerOpt1.SetTitle("Vimy Ridge");
                _map.AddMarker(markerOpt1);

                LatLng location = new LatLng(-19.9019194, -43.9462491);
                CameraPosition.Builder builder = CameraPosition.InvokeBuilder();
                builder.Target(location);
                builder.Zoom(18);
                builder.Bearing(155);
                builder.Tilt(65);
                CameraPosition cameraPosition = builder.Build();
                CameraUpdate   cameraUpdate   = CameraUpdateFactory.NewCameraPosition(cameraPosition);

                _map.MoveCamera(cameraUpdate);

                if (problemas != null && problemas.Any())
                {
                    foreach (Model.problema prob in problemas)
                    {
                        MarkerOptions markerOpt = new MarkerOptions();
                        markerOpt1.SetPosition(new LatLng(prob.latirude, prob.longitude));
                        Marker marker1 = _map.AddMarker(markerOpt1);

                        if (prob.problema_tipo_id == 1)
                        {
                            markerOpt1.SetTitle("Segurança");
                            markerOpt1.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueBlue));
                        }
                        else if (prob.problema_tipo_id == 1)
                        {
                            markerOpt1.SetTitle("Calçada Irregular");
                            markerOpt1.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueViolet));
                        }
                        else if (prob.problema_tipo_id == 1)
                        {
                            markerOpt1.SetTitle("Iluminação Pública");
                            markerOpt1.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueGreen));
                        }
                        else if (prob.problema_tipo_id == 1)
                        {
                            markerOpt1.SetTitle("Acidente");
                            markerOpt1.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueYellow));
                        }
                        _map.AddMarker(markerOpt1);
                    }
                }
            }
        }
示例#11
0
        protected override void OnResume()
        {
            base.OnResume();

            // Get a handle on the map element
            _mapFragment = FragmentManager.FindFragmentById(Resource.Id.map) as MapFragment;
            _map         = _mapFragment.Map;

            // Set the map type
            _map.MapType = GoogleMap.MapTypeNormal;

            // show user location
            _map.MyLocationEnabled = true;

            // setup a location manager
            _locationManager = GetSystemService(Context.LocationService) as LocationManager;

            #region Step 3b - Add Markers to the Google Map object
            // TODO: Step 3b - Add points on the map
            MarkerOptions marker1 = new MarkerOptions()
                                    .SetPosition(Location_Xamarin)
                                    .SetTitle("Xamarin")
                                    .InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueBlue));
            _map.AddMarker(marker1);

            MarkerOptions marker2 = new MarkerOptions()
                                    .SetPosition(Location_Atlanta)
                                    .SetTitle("Atlanta, GA")
                                    .InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueRed));
            var myMarker = _map.AddMarker(marker2);
            #endregion


            // TODO: Step 3c - Add custom marker images on the map
            AddMonkeyMarkersToMap();

            // TODO: Step 3d - Add custom arrow callout on map
            AddInitialNewYorkBarToMap();

            // TODO: Step 3e - Add custom overlay image on the map
            PositionChicagoGroundOverlay(Location_Chicago);

            // use a generic location provider instead
            Criteria locationCriteria = new Criteria();
            locationCriteria.Accuracy         = Accuracy.Coarse;
            locationCriteria.PowerRequirement = Power.Medium;

            var locationProvider = _locationManager.GetBestProvider(locationCriteria, true);
            if (locationProvider != null)
            {
                _locationManager.RequestLocationUpdates(locationProvider, 2000, 1, this);
            }
            else
            {
                Log.Info("error", "Best provider is not available. Does the device have location services enabled?");
            }
        }
示例#12
0
 private void SetMarkers()
 {
     foreach (var coord in Coords)
     {
         var marker = new MarkerOptions();
         marker.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueCyan));
         GMap.AddMarker(marker.SetPosition(coord));
     }
 }
        public async void getLastLocation(GoogleMap googleMap)
        {
            Console.WriteLine("Test - LastLoc");
            try
            {
                var location = await Geolocation.GetLastKnownLocationAsync();

                if (location != null)
                {
                    Console.WriteLine($"Last Loc - Latitude: {location.Latitude}, Longitude: {location.Longitude}, Altitude: {location.Altitude}");
                    MarkerOptions curLoc = new MarkerOptions();
                    curLoc.SetPosition(new LatLng(location.Latitude, location.Longitude));
                    var address = await Geocoding.GetPlacemarksAsync(location.Latitude, location.Longitude);

                    var placemark      = address?.FirstOrDefault();
                    var geocodeAddress = "";
                    if (placemark != null)
                    {
                        geocodeAddress =
                            $"AdminArea:       {placemark.AdminArea}\n" +
                            $"CountryCode:     {placemark.CountryCode}\n" +
                            $"CountryName:     {placemark.CountryName}\n" +
                            $"FeatureName:     {placemark.FeatureName}\n" +
                            $"Locality:        {placemark.Locality}\n" +
                            $"PostalCode:      {placemark.PostalCode}\n" +
                            $"SubAdminArea:    {placemark.SubAdminArea}\n" +
                            $"SubLocality:     {placemark.SubLocality}\n" +
                            $"SubThoroughfare: {placemark.SubThoroughfare}\n" +
                            $"Thoroughfare:    {placemark.Thoroughfare}\n";
                    }
                    curLoc.SetTitle("You were here" + geocodeAddress);
                    curLoc.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueAzure));
                    googleMap.AddMarker(curLoc);
                }
            }
            catch (FeatureNotSupportedException fnsEx)
            {
                // Handle not supported on device exception
                Toast.MakeText(this, "Feature Not Supported", ToastLength.Short);
            }
            catch (FeatureNotEnabledException fneEx)
            {
                // Handle not enabled on device exception
                Toast.MakeText(this, "Feature Not Enabled", ToastLength.Short);
            }
            catch (PermissionException pEx)
            {
                // Handle permission exception
                Toast.MakeText(this, "Needs more permission", ToastLength.Short);
            }
            catch (Exception ex)
            {
                // Unable to get location
                Toast.MakeText(this, "Unable to get location", ToastLength.Short);
            }
        }
        public async Task SetupMapIfNeeded()
        {
            //if (_map == null)
            //{

            if (_map != null)
            {
                var criteria = new Criteria {
                    PowerRequirement = Power.Medium
                };
                var bestProvider = locationManager.GetBestProvider(criteria, true);
                var location     = locationManager.GetLastKnownLocation(bestProvider);
                System.Diagnostics.Debug.WriteLine("start timer maps loc " + location.Latitude);
                MarkerOptions markerOpt1 = new MarkerOptions();

                VimyRidge  = new LatLng(location.Latitude, location.Longitude);
                markerOpt1 = new MarkerOptions();
                markerOpt1.SetPosition(VimyRidge);
                markerOpt1.SetTitle("Mi ubicación");
                markerOpt1.InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueCyan));
                _map.AddMarker(markerOpt1);



                List <Coord> requestCoord = await App.Database.GetAllCoordAsync();

                foreach (Coord item in requestCoord)
                {
                    System.Diagnostics.Debug.WriteLine("entra maps marker");
                    Passchendaele = new LatLng(Double.Parse(item.LATITUD), Double.Parse(item.LONGITUD));
                    markerOpt1    = new MarkerOptions();
                    markerOpt1.SetPosition(Passchendaele);
                    markerOpt1.SetTitle(item.CMADDRESS);
                    //markerOpt1.InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueCyan));
                    _map.AddMarker(markerOpt1);

                    //MarkerOptions markerOpt2 = new MarkerOptions();
                    //markerOpt2.SetPosition(Passchendaele);
                    //markerOpt2.SetTitle("Passchendaele");
                    //_map.AddMarker(markerOpt2);
                }

                // We create an instance of CameraUpdate, and move the map to it.        15

                //actualizacion de la posicion de la camara
                if (ind == 0)
                {
                    CameraUpdate cameraUpdate = CameraUpdateFactory.NewLatLngZoom(VimyRidge, 10);
                    _map.MoveCamera(cameraUpdate);
                    ind = 1;
                }
            }

            //}
        }
        private void MarkColor(LatLng pos, string title,
                               float color)
        {
            var markerOption = new MarkerOptions().SetPosition(pos);

            markerOption.SetTitle(title);
            var bmDescriptor = BitmapDescriptorFactory.DefaultMarker(color);

            markerOption.SetIcon(bmDescriptor);
            _googleMap.AddMarker(markerOption);
        }
示例#16
0
        public async void getCurrentLoc(GoogleMap googleMap)
        {
            Console.WriteLine("Test - CurrentLoc");
            try
            {
                var request  = new GeolocationRequest(GeolocationAccuracy.Medium);
                var location = await Geolocation.GetLocationAsync(request);

                if (location != null)
                {
                    Console.WriteLine($"current Loc - Latitude: {location.Latitude}, Longitude: {location.Longitude}, Altitude: {location.Altitude}");
                    MarkerOptions curLoc = new MarkerOptions();
                    curLoc.SetPosition(new LatLng(location.Latitude, location.Longitude));
                    curLoc.SetTitle("You are here");
                    curLoc.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueAzure));

                    googleMap.AddMarker(curLoc);
                    CameraPosition.Builder builder = CameraPosition.InvokeBuilder();
                    builder.Target(new LatLng(location.Latitude, location.Longitude));
                    builder.Zoom(18);
                    builder.Bearing(155);
                    builder.Tilt(65);

                    CameraPosition cameraPosition = builder.Build();

                    CameraUpdate cameraUpdate = CameraUpdateFactory.NewCameraPosition(cameraPosition);

                    googleMap.MoveCamera(cameraUpdate);
                }
                else
                {
                    getLastLocation(googleMap);
                }
            }
            catch (FeatureNotSupportedException fnsEx)
            {
                // Handle not supported on device exception
                Toast.MakeText(this, "Feature Not Supported", ToastLength.Short);
            }
            catch (FeatureNotEnabledException fneEx)
            {
                // Handle not enabled on device exception
                Toast.MakeText(this, "Feature Not Enabled", ToastLength.Short);
            }
            catch (PermissionException pEx)
            {
                // Handle permission exception
                Toast.MakeText(this, "Needs more permission", ToastLength.Short);
            }
            catch (Exception ex)
            {
                getLastLocation(googleMap);
            }
        }
 private void Initialize()
 {
     if (!string.IsNullOrEmpty(Pushpin.Icon))
     {
         MarkerOptions.SetIcon(BitmapDescriptorFactory.FromAsset(Pushpin.Icon));
     }
     else
     {
         MarkerOptions.SetIcon(BitmapDescriptorFactory.DefaultMarker());
     }
 }
示例#18
0
        private void Addmarker(LatLng position, string title, string snippet)
        {
            var markerOptions = new MarkerOptions();

            markerOptions.SetPosition(position);
            markerOptions.SetTitle(title);
            markerOptions.InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueCyan));
            markerOptions.SetSnippet(snippet);

            _map.AddMarker(markerOptions);
        }
示例#19
0
 public void InitMarkers()
 {
     foreach (var element in ListMarkers)
     {
         MarkerOptions markerOptions = new MarkerOptions();
         markerOptions.SetPosition(new LatLng(element.Coordinate.Latitude, element.Coordinate.Longitude));
         markerOptions.SetIcon(BitmapDescriptorFactory.DefaultMarker());
         var marker = this.map.AddMarker(markerOptions);
         this.listMarkers.Add(marker);
     }
 }
示例#20
0
        private MarkerOptions BuildMarker(int playerPosition)
        {
            Log.Debug("BuildMarker", "Building marker");

            MarkerOptions markerOptions = new MarkerOptions();

            markerOptions.SetIcon(BitmapDescriptorFactory.DefaultMarker(Colour(playerPosition)));
            markerOptions.SetPosition(gameActivity.playerArray[playerPosition].currentPosition);

            return(markerOptions);
        }
示例#21
0
 protected virtual void OnPinPropertyChanged(MapPin pin, Marker marker, PropertyChangedEventArgs e)
 {
     if (e.PropertyName == MapPin.ColorProperty.PropertyName)
     {
         marker.SetIcon(BitmapDescriptorFactory.DefaultMarker(pin.Color.ToAndroidMarkerHue()));
     }
     else if (e.PropertyName == MapPin.PositionProperty.PropertyName)
     {
         marker.Position = pin.Position.ToLatLng();
     }
 }
示例#22
0
        public static MarkerOptions MarkCity(float color)
        {
            MarkerOptions markerOpt1 = new MarkerOptions();

            markerOpt1.SetPosition(new LatLng(latP, lonP));
            markerOpt1.SetTitle(namePlaces);
            var bmDescriptor = BitmapDescriptorFactory.DefaultMarker(color);

            markerOpt1.SetIcon(bmDescriptor);
            return(markerOpt1);
        }
示例#23
0
 private Pin generate_pin(double lat, double lng, string id, string code, Color cor)
 {
     return(new Pin
     {
         Type = PinType.Place,
         Icon = BitmapDescriptorFactory.DefaultMarker(cor),
         Position = new Position(lat, lng),
         Tag = id,
         Label = code,
         IsDraggable = true
     });
 }
示例#24
0
        public void OnMapReady(GoogleMap googleMap)
        {
            mMap = googleMap;
            LatLng       latlng = new LatLng(loc.Latitude, loc.Longitude); //Wijnhaven
            CameraUpdate camera = CameraUpdateFactory.NewLatLngZoom(latlng, 15);

            mMap.MoveCamera(camera);
            MarkerOptions start = new MarkerOptions()
                                  .SetPosition(latlng)
                                  .SetTitle("Uw huidige locatie")
                                  .SetSnippet("U bevind zich hier")
                                  .SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueBlue));

            mMap.AddMarker(start);
            MarkerFactory mFactory = new MarkerFactory(preLoad.csvFT.getMarkers());
            float         lowest   = 99999;

            for (Iterator iter = mFactory.getIterator(); iter.hasNext();)
            {
                FietsTrommel ft = iter.next();
                if (ft.xcoord.Length > 0 && ft.ycoord.Length > 0)
                {
                    double   lat    = Convert.ToDouble(ft.xcoord.Replace('.', ','));
                    double   lon    = Convert.ToDouble(ft.ycoord.Replace('.', ','));
                    Location fietsT = new Location("");
                    fietsT.Latitude  = lat;
                    fietsT.Longitude = lon;

                    if (fietsT.DistanceTo(loc) < 500)
                    {
                        LatLng        coords    = new LatLng(lat, lon);
                        MarkerOptions newMarker = new MarkerOptions()
                                                  .SetPosition(coords)
                                                  .SetTitle(ft.Straat)
                                                  .SetSnippet("Sinds: " + ft.Mutdatum)
                                                  .Draggable(true);

                        mMap.AddMarker(newMarker);
                    }
                    if (fietsT.DistanceTo(loc) < lowest)
                    {
                        lowest  = fietsT.DistanceTo(loc);
                        closest = ft;
                    }
                }
            }
            Location closestF = new Location("");
            double   closLat  = Convert.ToDouble(closest.xcoord.Replace('.', ','));
            double   closLon  = Convert.ToDouble(closest.ycoord.Replace('.', ','));

            closestF.Latitude  = closLat;
            closestF.Longitude = closLon;
        }
示例#25
0
 private void AddMarker(MapPin pin)
 {
     using (var op = new MarkerOptions())
     {
         op.SetTitle(pin.Label);
         op.SetPosition(pin.Position.ToLatLng());
         op.SetIcon(BitmapDescriptorFactory.DefaultMarker(pin.Color.ToAndroidMarkerHue()));
         var marker = NativeMap.AddMarker(op);
         pin.Id = marker.Id;
         Markers.Add(pin, marker);
     }
 }
示例#26
0
        public void OnMapReady(GoogleMap googleMap)
        {
            _map = googleMap;

            if (_map != null)
            {
                MarkerOptions markerOpt1 = new MarkerOptions();
                markerOpt1.SetPosition(new LatLng(ViewModel.Latitude, ViewModel.Longitude));
                markerOpt1.SetTitle("Stadium");
                markerOpt1.InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueCyan));
                _map.AddMarker(markerOpt1);
            }
        }
示例#27
0
        private void addMarker(GoogleMap map, LatLng location)
        {
            MarkerOptions markerOpt1 = new MarkerOptions();

            markerOpt1.SetPosition(location);
            markerOpt1.SetTitle("My Location!");

            var bmDescriptor = BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueCyan);

            markerOpt1.InvokeIcon(bmDescriptor);

            map.AddMarker(markerOpt1);
        }
        public static MarkerOptions CreateMarker(LatLng position, string title, string snippet, float color)
        {
            MarkerOptions mo = new MarkerOptions();

            mo.SetPosition(position);
            // Nombre del Establecimiento
            mo.SetTitle(title);
            // Direccion del Establecimiento
            mo.SetSnippet(snippet);
            mo.SetIcon(BitmapDescriptorFactory.DefaultMarker(color));

            return(mo);
        }
示例#29
0
        private void updateMapFromDictionary(int index)
        {
            var map = mapFragment.Map;

            if (map != null)
            {
                map.Clear();

                displayingIndex = index;

                updatePrevNextButtonVisibility(index);

                From   fromPlace  = fromNameDictionary [index];
                LatLng fromLatLng = new LatLng(fromPlace.lat, fromPlace.lon);

                if (displayingIndex == 0)
                {
                    txtMapDesc.Text = "Overview Map";
                }
                else
                {
                    txtMapDesc.Text = "Step " + index.ToString();
                }


                MarkerOptions fromMarkerOpt = new MarkerOptions();
                fromMarkerOpt.SetPosition(fromLatLng);
                fromMarkerOpt.SetTitle(fromPlace.name);
                fromMarkerOpt.InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueGreen));

                var fromMarker = map.AddMarker(fromMarkerOpt);

                To            toPlace     = toNameDictionary [index];
                LatLng        toLatLng    = new LatLng(toPlace.lat, toPlace.lon);
                MarkerOptions toMarkerOpt = new MarkerOptions();
                toMarkerOpt.SetPosition(toLatLng);
                toMarkerOpt.SetTitle(toPlace.name);
                toMarkerOpt.InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueRed));

                var toMarker = map.AddMarker(toMarkerOpt);

                PolylineOptions polylineOptions = polylineDictionary [index];
                var             polyline        = map.AddPolyline(polylineOptions);

                LatLngBounds bounds       = findMapBounds(polylineOptions);
                CameraUpdate cameraUpdate = CameraUpdateFactory.NewLatLngBounds(bounds, 50);

                //map.AnimateCamera(cameraUpdate);
                map.MoveCamera(cameraUpdate);
            }
        }
示例#30
0
        public MapPage()
        {
            InitializeComponent();
            MapViewModel = (MapViewModel)BindingContext;

            MessagingCenter.Subscribe <string, Position>("MapUpdate", "MoveTo", (sender, pos) =>
            {
                map.Pins.Clear();
                var pin = new Pin()
                {
                    Type      = PinType.Place,
                    Label     = "Your current location",
                    Position  = new Position(pos.Latitude, pos.Longitude),
                    Icon      = BitmapDescriptorFactory.DefaultMarker(Color.Blue),
                    Tag       = "current_location",
                    IsVisible = true
                };
                map.Pins.Add(pin);
                map.MoveToRegion(MapSpan.FromCenterAndRadius(pos, Xamarin.Forms.GoogleMaps.Distance.FromMeters(5000)));
            });


            MessagingCenter.Subscribe <string, List <AirportModel> >("MapUpdate", "PushPins", (sender, pins) =>
            {
                pins.ForEach((pinModel) =>
                {
                    try
                    {
                        var lat = Double.Parse(pinModel.latitudeAirport);
                        var lon = Double.Parse(pinModel.longitudeAirport);
                        var pos = new Position(lat, lon);
                        var pin = new Pin()
                        {
                            Type      = PinType.Place,
                            Label     = $"{pinModel.nameAirport}({pinModel.codeIataAirport}), {pinModel.nameCountry}",
                            Position  = pos,
                            Icon      = BitmapDescriptorFactory.DefaultMarker(Color.Red),
                            Tag       = pinModel.codeIataAirport,
                            IsVisible = true
                        };
                        map.Pins.Add(pin);
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                });
            });

            map.PinClicked += Map_PinClicked;
        }