Exemplo n.º 1
0
        void LocationChanged(object sender, LocationEventArgs e)
        {
            activity.RunOnUiThread(delegate {
                LatLng ll = RandomLatLng();

                MarkerOptions opts = new MarkerOptions();
                opts.SetPosition(RandomLatLng());
                opts.SetTitle(ll.Latitude + ", " + ll.Longitude);
                if (fish)
                {
                    opts.SetSnippet("Fish caught");
                }
                else
                {
                    opts.SetSnippet("No fish");
                }

                m.Remove();

                m = googleMap.AddMarker(opts);

                if (infoVisible)
                {
                    m.ShowInfoWindow();
                }

                //googleMap.MoveCamera (CameraUpdateFactory.NewLatLng (new LatLng (e.Lat, e.Lon)));
            });
        }
Exemplo n.º 2
0
        public void OnMapReady(MapboxMap map)
        {
            var uiSettings = map.UiSettings;

            uiSettings.SetAllGesturesEnabled(true);

            var marker = new MarkerOptions();

            marker.SetTitle("Los Angeles");
            marker.SetSnippet("City Hall");
            marker.SetPosition(LOS_ANGELES);

            map.AddMarker(marker);

            marker.SetTitle("New York");
            marker.SetSnippet("City Hall");
            marker.SetPosition(NEW_YORK);

            map.AddMarker(marker);

            var bounds = new LatLngBounds.Builder()
                         .Include(NEW_YORK)
                         .Include(LOS_ANGELES)
                         .Build();

            map.MoveCamera(CameraUpdateFactory.NewLatLngBounds(bounds, 8));
        }
Exemplo n.º 3
0
        protected override MarkerOptions CreateMarker(Pin pin)
        {
            if (pin is CirclePin)
            {
                //create an overlay circle, and add to map
                var circleOptions = new CircleOptions();
                circleOptions.InvokeCenter(new LatLng(pin.Position.Latitude, pin.Position.Longitude));
                circleOptions.InvokeRadius(PublishedData.PinOverlayRadius);
                circleOptions.InvokeFillColor(0X66FF0000);
                circleOptions.InvokeStrokeColor(0X66FF0000);
                circleOptions.InvokeStrokeWidth(0);
                Circle circle = NativeMap.AddCircle(circleOptions);
                (pin as CirclePin).Overlay = circle;
            }

            // marker,or pin.
            var marker = new MarkerOptions();

            marker.SetPosition(new LatLng(pin.Position.Latitude, pin.Position.Longitude));
            marker.Anchor(0.5f, 0.5f);// set anchor to to middle of icon
            marker.SetTitle(pin.Label);
            marker.SetSnippet(pin.Address);
            Bitmap imageBitmap = BitmapFactory.DecodeResource(Resources, Resource.Drawable.pin);
            Bitmap resizedIcon = Bitmap.CreateScaledBitmap(imageBitmap, 50, 50, false);

            marker.SetIcon(BitmapDescriptorFactory.FromBitmap(resizedIcon));

            return(marker);
        }
Exemplo n.º 4
0
        protected override async void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);

            if (e.PropertyName.Equals(nameof(CustomMap.CustomPins)) && GoogleMap != null)
            {
                GoogleMap.Clear();
                var formsMap   = (CustomMap)Element;
                var customPins = formsMap.CustomPins;
                if (customPins == null)
                {
                    return;
                }

                foreach (var pin in customPins)
                {
                    var marker = new MarkerOptions();
                    marker.SetPosition(new LatLng(pin.Latitude, pin.Longitude));
                    marker.SetTitle(pin.Label);
                    marker.SetSnippet(pin.Address);

                    var bitm = await ImageService.Instance.LoadUrl(pin.Url).AsBitmapDrawableAsync();

                    marker.SetIcon(BitmapDescriptorFactory.FromBitmap(bitm.Bitmap));

                    GoogleMap.AddMarker(marker);
                }
            }
        }
Exemplo n.º 5
0
        // Methods (override)
        #region CreateMarker(Pin)

        /// <summary>
        /// 마커의 위치와 라벨을 설정합니다.
        /// </summary>
        /// <param name="pin"></param>
        /// <returns></returns>
        protected override MarkerOptions CreateMarker(Pin pin)
        {
            CustomPin customPin = pin as CustomPin;

            if (customPin == null)
            {
                return(null);
            }

            var marker = new MarkerOptions();

            try
            {
                marker.SetPosition(new LatLng(pin.Position.Latitude, pin.Position.Longitude));
                marker.SetTitle(customPin.Name);
                marker.SetSnippet(pin.Address);
                marker.SetIcon(GenerateMyCustomDrawnOverlay(125, 60, customPin.Label));
            }
            catch
            {
                // 에러무시
            }

            return(marker);
        }
        private void LoadPins(object sender)
        {
            if (Control != null)
            {
                var formsMap = (ExtendedMap)sender;

                NativeMap.Clear();
                if (formsMap.ItemsSource != null)
                {
                    var formsPins = formsMap.ItemsSource;

                    foreach (var formsPin in formsPins)
                    {
                        var markerWithIcon = new MarkerOptions();

                        markerWithIcon.SetPosition(new LatLng(formsPin.Latitude, formsPin.Longitude));
                        markerWithIcon.SetTitle(formsPin.Name);
                        markerWithIcon.SetSnippet(formsPin.Description);
                        markerWithIcon.SetIcon(BitmapDescriptorFactory.FromResource(GetPinIcon()));

                        NativeMap.AddMarker(markerWithIcon);
                    }
                }
            }
        }
Exemplo n.º 7
0
        /* public  async void GetPosition(GoogleMap googleMap)
         * {
         *   try
         *   {
         *       var locator = CrossGeolocator.Current;
         *           locator.DesiredAccuracy = 50;
         *       if (locator.IsGeolocationEnabled)
         *       {
         *           var position = await locator.GetPositionAsync(TimeSpan.FromSeconds(1000));
         *           LatLng coordonne = new LatLng(position.Latitude, position.Longitude);
         *           MarkerOptions markerOptions = new MarkerOptions();
         *           markerOptions.SetPosition(new LatLng(position.Latitude, position.Longitude));
         *           markerOptions.SetTitle("Ma Position");
         *           googleMap.AddMarker(markerOptions);
         *           googleMap.MoveCamera(CameraUpdateFactory.NewLatLng(coordonne));
         *       }
         *       else
         *       {
         *           Console.WriteLine("La location ne trouve pas, geolocator est éteint.");
         *       }
         *
         *
         *   }
         *   catch (Exception le)
         *   {
         *
         *       Console.WriteLine(le+"La location ne trouve pas.");
         *   }
         * }*/

        public void GetLocationFromAddress(string strAddress, int id, GoogleMap googleMap)
        {
            Geocoder coder = new Geocoder(this);

            IList <Address> address       = null;
            MarkerOptions   markerOptions = new MarkerOptions();

            markerOptions.SetSnippet(strAddress);
            address = coder.GetFromLocationName(strAddress, 5);
            if (address == null)
            {
                return;
            }
            else
            {
                for (int i = 0; i < address.Count; i++)
                {
                    Address ad = address[i];

                    markerOptions.SetPosition(new LatLng(ad.Latitude, ad.Longitude));
                    markerOptions.SetTitle(listArtisan[id]);

                    googleMap.AddMarker(markerOptions);
                }
                googleMap.SetInfoWindowAdapter(this);
            }
        }
Exemplo n.º 8
0
        public void OnMapReady(GoogleMap googleMap)
        {
            LatLng belmont = new LatLng(-31.9798264, 115.7799933);

            CameraUpdate camera = CameraUpdateFactory.NewLatLngZoom(belmont, 15);

            MarkerOptions markerOptions = new MarkerOptions();

            markerOptions.SetPosition(new LatLng(-31.9798264, 115.7799933));
            markerOptions.SetTitle("Claremont Trails");
            markerOptions.SetSnippet("Start Here");
            googleMap.AddMarker(markerOptions);

            MarkerOptions markerOptions2 = new MarkerOptions();

            markerOptions2.SetPosition(new LatLng(-31.980699, 115.7813756));
            markerOptions2.SetTitle("Claremont Trails Finish");
            markerOptions2.SetSnippet("End Here");
            googleMap.AddMarker(markerOptions2);

            //Optional fluff
            googleMap.UiSettings.ZoomControlsEnabled = true;
            googleMap.UiSettings.CompassEnabled      = true;
            googleMap.MoveCamera(CameraUpdateFactory.ZoomIn());
            googleMap.UiSettings.ZoomGesturesEnabled = false;
        }
        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);

            if (e.PropertyName.Equals("VisibleRegion") && !isDrawn)
            {
                NativeMap.Clear();
                NativeMap.InfoWindowClick += OnInfoWindowClick;
                NativeMap.SetInfoWindowAdapter(this);

                // for route
                //var polylineOptions = new PolylineOptions();
                //polylineOptions.InvokeColor(0x66FF0000);

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

                //NativeMap.AddPolyline(polylineOptions);

                // for pins
                foreach (var pin in customPins)
                {
                    var marker = new MarkerOptions();
                    marker.SetPosition(new LatLng(pin.Pin.Position.Latitude, pin.Pin.Position.Longitude));
                    marker.SetTitle(pin.Pin.Label);
                    marker.SetSnippet(pin.Pin.Address);
                    marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.pin));

                    NativeMap.AddMarker(marker);
                }
                isDrawn = true;
            }
        }
        /// <summary>
        /// Creates a pin and sets the icon of it according to what type of pin it is.
        /// If it is a ship pin, it rotates the pin according to the direction of the ship
        /// </summary>
        /// <param name="pin">The pin that will be created</param>
        /// <returns>The MarkerOptions for the pin</returns>
        protected override MarkerOptions CreateMarker(Pin pin)
        {
            var marker = new MarkerOptions();

            marker.SetPosition(new LatLng(pin.Position.Latitude, pin.Position.Longitude));
            marker.SetTitle(pin.Label);
            marker.SetSnippet(pin.Address);
            if (!String.IsNullOrEmpty(pin.Address))
            {
                if (sharedData.SelectedShipId == int.Parse(pin.Address))
                {
                    marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.markedBoatIcon));
                }
                else
                {
                    marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.boaticon));
                }
                marker.SetRotation((sharedData.Direction) - rotationOffset);
            }
            else
            {
                if (pin.Label.ToLower().Equals("startline"))
                {
                    marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.startIconR));
                }
                else if (pin.Label.ToLower().Equals("finishline"))
                {
                    marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.finishiconR));
                }
            }
            return(marker);
        }
Exemplo n.º 11
0
        private void DrawPins()
        {
            if (GoogleMap != null)
            {
                GoogleMap.Clear();
                GoogleMap.MarkerClick += (sender, args) =>
                {
                    var position = new Position(args.Marker.Position.Latitude, args.Marker.Position.Longitude);
                    FormsMap.MoveToRegion(MapSpan.FromCenterAndRadius(position, MapDistance));

                    if (args.Marker.Title.Equals("Owner"))
                    {
                        return;
                    }
                    args.Marker.ShowInfoWindow();
                };

                foreach (var pin in Pins)
                {
                    var marker = new MarkerOptions();
                    marker.SetPosition(new LatLng(pin.Position.Latitude, pin.Position.Longitude));
                    marker.SetTitle(pin.Label);
                    marker.SetSnippet(pin.Address);
                    marker.SetIcon(GetPinIcon(pin.Type));
                    GoogleMap.AddMarker(marker);
                }
            }
        }
Exemplo n.º 12
0
        protected MarkerOptions CreateCustomMarker(CustomPin pin)
        {
            MarkerOptions marker = new MarkerOptions();

            marker.SetPosition(new LatLng(pin.Position.Latitude, pin.Position.Longitude));
            marker.SetTitle(pin.Label);
            marker.SetSnippet(pin.Address);

            //   if (pin.Id.ToString() == "hasClicked")
            CustomPin customP = null;

            foreach (var p in map.Pins)
            {
                if (p.Position == pin.Position)
                {
                    customP = (CustomPin)p;
                    break;
                }
            }
            if (customP.hasClicked)
            {
                marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.pinBlue));
            }
            else if (customP.isYourLocation)
            {
                marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.pinAq));
            }
            else
            {
                marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.pin));
            }
            return(marker);
        }
Exemplo n.º 13
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));
        }
Exemplo n.º 14
0
        public void OnMapReady(GoogleMap googleMap)
        {
            LatLng latlng = null;

            this.Gmap = googleMap;
            Gmap.UiSettings.ZoomControlsEnabled = true;
            Gmap.UiSettings.ZoomGesturesEnabled = true;

            LatLngBounds.Builder builder = new LatLngBounds.Builder();

            _auditDetailList   = manageTemplate.GetAllAudit();
            _auditTemplateList = manageTemplate.GetTemplates();
            foreach (AuditDetails auditDetail in _auditDetailList)
            {
                string[] gpsCoordinates = auditDetail.GPSCoordinate.Split(',');
                if (gpsCoordinates.Count() > 0)
                {
                    latlng = new LatLng(Convert.ToDouble(gpsCoordinates[0]), Convert.ToDouble(gpsCoordinates[1]));
                    MarkerOptions options         = new MarkerOptions().SetPosition(latlng).SetAlpha(auditDetail.Id);
                    var           templatedetails = _auditTemplateList.Find(t => t.Id == auditDetail.TemplateId);
                    options.SetTitle(templatedetails.Name);
                    options.SetSnippet(auditDetail.Location + " - " + DateTime.Today.ToShortDateString());

                    Gmap.AddMarker(options);
                    builder.Include(latlng);
                }
            }

            LatLngBounds bounds = builder.Build();
            CameraUpdate cu     = CameraUpdateFactory.NewLatLngBounds(bounds, Resources.DisplayMetrics.WidthPixels, Resources.DisplayMetrics.HeightPixels, 120);

            googleMap.MoveCamera(cu);

            Gmap.InfoWindowClick += Gmap_InfoWindowClick;
        }
        private void updateAllPins()
        {
            if (this.customPins != null)
            {
                if (this.map != null)
                {
                    int nOdx   = 0;
                    int nCount = 0;

                    this.map.Clear();

                    nCount = this.customPins.Count;
                    for (nOdx = 0; nOdx < nCount; nOdx++)
                    {
                        MarkerOptions marker = new MarkerOptions();
                        marker.SetPosition(new LatLng(this.customPins[nOdx].Latitude, this.customPins[nOdx].Longitude));
                        marker.SetTitle(this.customPins[nOdx].Label);
                        marker.SetSnippet(this.customPins[nOdx].Address);
                        if (this.customPins[nOdx].BluePin)
                        {
                            marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.bluemappin50));
                            Logger.LogInfo("CustomMapRenderer", "Blue Pin at: {0}, {1}", this.customPins[nOdx].Latitude, this.customPins[nOdx].Longitude);
                        }
                        else
                        {
                            marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.orangemappin50));
                            Logger.LogInfo("CustomMapRenderer", "Orange Pin at: {0}, {1}", this.customPins[nOdx].Latitude, this.customPins[nOdx].Longitude);
                        }

                        this.map.AddMarker(marker);
                    }
                }
            }
        }
        protected override MarkerOptions CreateMarker(Pin pin)
        {
            var marker = new MarkerOptions();

            marker.SetPosition(new LatLng(pin.Position.Latitude, pin.Position.Longitude));
            marker.SetTitle(pin.Label);
            marker.SetSnippet(pin.Address);
            if (pin.Label.Contains("SECTOR 1"))
            {
                marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.corregidora1));
            }
            else if (pin.Label.Contains("SECTOR 2"))
            {
                marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.corregidora2));
            }
            else if (pin.Label.Contains("SECTOR 3"))
            {
                marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.corregidora3));
            }
            else if (pin.Label.Contains("SECTOR 4"))
            {
                marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.corregidora4));
            }
            else if (pin.Label.Contains("SECTOR 5"))
            {
                marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.corregidora5));
            }
            else
            {
                marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.corregidora));
            }

            return(marker);
        }
Exemplo n.º 17
0
        private void UpdateMapView()
        {
            var mapReadyCallback = new LocalMapReady();

            mapReadyCallback.MapReady += (sender, args) =>
            {
                googleMap = (sender as LocalMapReady).Map;

                if (googleMap != null)
                {
                    MarkerOptions markerOptions = new MarkerOptions();
                    markerOptions.SetPosition(dealLocation);
                    markerOptions.SetTitle("Deals in Your Areaa");
                    markerOptions.SetSnippet("This User is available in your area");

                    googleMap.AddMarker(markerOptions);
                    CameraUpdate cameraUpdate = CameraUpdateFactory.NewLatLngZoom(dealLocation, 15);
                    googleMap.MoveCamera(cameraUpdate);


                    MarkerOptions markerOptions2 = new MarkerOptions();
                    markerOptions2.SetPosition(dealLocation2);
                    markerOptions2.SetTitle("Mr D");
                    markerOptions2.SetSnippet("Contact this User Now!");
                    googleMap.AddMarker(markerOptions2);
                    CameraUpdate cameraUpdate2 = CameraUpdateFactory.NewLatLngZoom(dealLocation2, 15);
                    googleMap.MoveCamera(cameraUpdate2);
                }
            };

            mapFragment.GetMapAsync(mapReadyCallback);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Adds a marker to the map
        /// </summary>
        /// <param name="pin">The Forms Pin</param>
        private async void AddPin(TKCustomMapPin pin)
        {
            pin.PropertyChanged += OnPinPropertyChanged;

            var markerWithIcon = new MarkerOptions();

            markerWithIcon.SetPosition(new LatLng(pin.Position.Latitude, pin.Position.Longitude));

            if (!string.IsNullOrWhiteSpace(pin.Title))
            {
                markerWithIcon.SetTitle(pin.Title);
            }
            if (!string.IsNullOrWhiteSpace(pin.Subtitle))
            {
                markerWithIcon.SetSnippet(pin.Subtitle);
            }

            await this.UpdateImage(pin, markerWithIcon);

            markerWithIcon.Draggable(pin.IsDraggable);
            markerWithIcon.Visible(pin.IsVisible);
            if (pin.Image != null)
            {
                markerWithIcon.Anchor((float)pin.Anchor.X, (float)pin.Anchor.Y);
            }

            this._markers.Add(pin, this._googleMap.AddMarker(markerWithIcon));
        }
Exemplo n.º 19
0
        void AddPins(IList pins)
        {
            GoogleMap map = NativeMap;

            if (map == null)
            {
                return;
            }

            if (_markers == null)
            {
                _markers = new List <Marker>();
            }

            _markers.AddRange(pins.Cast <Pin>().Select(p =>
            {
                Pin pin  = p;
                var opts = new MarkerOptions();
                opts.SetPosition(new LatLng(pin.Position.Latitude, pin.Position.Longitude));
                opts.SetTitle(pin.Label);
                opts.SetSnippet(pin.Address);
                var marker = map.AddMarker(opts);

                // associate pin with marker for later lookup in event handlers
                pin.Id = marker.Id;
                return(marker);
            }));
        }
        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);

            //System.Console.WriteLine("THis is customPins count: " + customPins.Count);

            if (e.PropertyName.Equals("VisibleRegion") && !isDrawn)
            {
                var formsMap = (CustomMap)Element;
                NativeMap.Clear();
                NativeMap.InfoWindowClick += OnInfoWindowClick;
                NativeMap.SetInfoWindowAdapter(this);

                foreach (var pin in formsMap.CustomPins)
                {
                    var marker = new MarkerOptions();
                    marker.SetPosition(new LatLng(pin.Pin.Position.Latitude, pin.Pin.Position.Longitude));
                    marker.SetTitle(pin.Pin.Label);
                    marker.SetSnippet(pin.Pin.Address);
                    //marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.pin));

                    NativeMap.AddMarker(marker);
                }
                isDrawn = true;
            }
        }
Exemplo n.º 21
0
        private void UpdatePins()
        {
            var androidMapView = (MapView)Control;
            var formsMap       = (ExtendedMap)Element;

            androidMapView.Map.Clear();

            androidMapView.Map.MarkerClick      += HandleMarkerClick;
            androidMapView.Map.MyLocationEnabled = formsMap.IsShowingUser;

            if (formsMap.ItemsSource != null)
            {
                if (this.markers == null)
                {
                    this.markers = new List <Marker> ();
                }

                var items = formsMap.ItemsSource.Cast <IMapModel> ();

                foreach (var item in items)
                {
                    var markerWithIcon = new MarkerOptions();

                    markerWithIcon.SetPosition(new LatLng(item.Location.Latitude, item.Location.Longitude));
                    markerWithIcon.SetTitle(string.IsNullOrWhiteSpace(item.Name) ? "-" : item.Name);
                    markerWithIcon.SetSnippet(item.Details);

                    markerWithIcon.InvokeIcon(BitmapDescriptorFactory.DefaultMarker());

                    var addedMarker = androidMapView.Map.AddMarker(markerWithIcon);
                    this.markers.Add(addedMarker);
                }
            }
        }
Exemplo n.º 22
0
        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);

            if (e.PropertyName.Equals("VisibleRegion") && !isDrawn)
            {
                map.Clear();

                if (customPins != null)
                {
                    foreach (var pin in customPins)
                    {
                        var marker = new MarkerOptions();
                        marker.SetPosition(new LatLng(pin.Pin.Position.Latitude, pin.Pin.Position.Longitude));
                        marker.SetTitle(pin.Pin.Label);
                        marker.SetSnippet(pin.Pin.Address);
                        marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.pin));

                        map.AddMarker(marker);
                    }

                    isDrawn = true;
                }
            }
        }
Exemplo n.º 23
0
        private void UpdatePins()
        {
            var androidMapView = (MapView)Control;
            var formsMap       = (CustomMap)Element;

            androidMapView.Map.Clear();

            androidMapView.Map.MarkerClick      += HandleMarkerClick;
            androidMapView.Map.MyLocationEnabled = formsMap.IsShowingUser;
            UpdateTile();

            var items = formsMap.Items;

            foreach (var item in items)
            {
                var markerWithIcon = new MarkerOptions();
                markerWithIcon.SetPosition(new LatLng(item.Location.Latitude, item.Location.Longitude));
                markerWithIcon.SetTitle(string.IsNullOrWhiteSpace(item.Name) ? "-" : item.Name);
                markerWithIcon.SetSnippet(item.Details);

                try
                {
                    markerWithIcon.InvokeIcon(BitmapDescriptorFactory.FromResource(GetPinIcon()));
                }
                catch (Exception)
                {
                    markerWithIcon.InvokeIcon(BitmapDescriptorFactory.DefaultMarker());
                }

                androidMapView.Map.AddMarker(markerWithIcon);
            }
        }
Exemplo n.º 24
0
        private void updateEpins()
        {
            var androidMapView = (MapView)Control;
            var formsMap       = (Xam.Plugin.MapExtend.Abstractions.MapExtend)Element;

            androidMapView.Map.Clear();

            androidMapView.Map.MarkerClick      += HandleMarkerClick;
            androidMapView.Map.MyLocationEnabled = formsMap.IsShowingUser;

            var items = formsMap.EPins;

            foreach (var item in items)
            {
                var markerWithIcon = new MarkerOptions();
                markerWithIcon.SetPosition(new LatLng(item.Location.Latitude, item.Location.Longitude));
                markerWithIcon.SetTitle(string.IsNullOrWhiteSpace(item.Name) ? "-" : item.Name);
                markerWithIcon.SetSnippet(item.Details);

                try
                {
                    markerWithIcon.InvokeIcon(BitmapDescriptorFactory.FromResource(Resources.GetIdentifier(item.ResourceNameImg, "drawable", Context.PackageName)));
                }
                catch (Exception)
                {
                    markerWithIcon.InvokeIcon(BitmapDescriptorFactory.DefaultMarker());
                }

                androidMapView.Map.AddMarker(markerWithIcon);
            }
        }
Exemplo n.º 25
0
        private void AddPushPins(MapView mapView, IEnumerable <CustomPin> pins)
        {
            foreach (var formsPin in pins)
            {
                var markerWithIcon = new MarkerOptions();

                markerWithIcon.SetPosition(new LatLng(formsPin.Position.Latitude, formsPin.Position.Longitude));
                markerWithIcon.SetTitle(formsPin.Label);
                markerWithIcon.SetSnippet(formsPin.Address);

                if (!string.IsNullOrEmpty(formsPin.PinIcon))
                {
                    markerWithIcon.SetIcon(_pinIcon);
                }
                else
                {
                    markerWithIcon.SetIcon(BitmapDescriptorFactory.DefaultMarker());
                }

                mapView.Map.AddMarker(markerWithIcon);

                _tempMarkers.Add(new CustomMarkerOptions
                {
                    Id            = formsPin.Id,
                    MarkerOptions = markerWithIcon
                });
            }
        }
Exemplo n.º 26
0
        private void UpdatePins()
        {
            var mapTile = (MapTile)Element;

            NativeMap.Clear();

            var pinItems = mapTile.PinList;

            foreach (var pinItem in pinItems)
            {
                var imageBytes = pinItem.PrimaryCategory.GetIconThemeBytes();
                var icon       = BitmapFactory.DecodeByteArray(imageBytes, 0, imageBytes.Length);

                var marker = new MarkerOptions();
                marker.SetPosition(new LatLng(pinItem.Latitude, pinItem.Longitude));
                marker.SetSnippet(pinItem.Id);
                marker.SetIcon(BitmapDescriptorFactory.FromBitmap(icon));

                NativeMap.AddMarker(marker);
            }

            if (LocationMarkerOptions.Position != null)
            {
                LocationMarker = NativeMap.AddMarker(LocationMarkerOptions);
            }

            UpdateLocationPinPosition();
        }
Exemplo n.º 27
0
        /// <summary>
        /// initializes the <see cref="MarkerOptions"/>
        /// </summary>
        /// <param name="markerOptions">Instance of the marker options</param>
        /// <param name="setPosition">if <value>true</value>, the position will be updated</param>
        /// <returns><see cref="Task"/></returns>
        public async Task InitializeMarkerOptionsAsync(MarkerOptions markerOptions, bool setPosition = true)
        {
            if (setPosition)
            {
                markerOptions.SetPosition(new LatLng(Pin.Position.Latitude, Pin.Position.Longitude));
            }

            if (!string.IsNullOrWhiteSpace(Pin.Title))
            {
                markerOptions.SetTitle(Pin.Title);
            }
            if (!string.IsNullOrWhiteSpace(Pin.Subtitle))
            {
                markerOptions.SetSnippet(Pin.Subtitle);
            }

            await UpdateImageAsync(markerOptions);

            markerOptions.Draggable(Pin.IsDraggable);
            markerOptions.Visible(Pin.IsVisible);
            markerOptions.SetRotation((float)Pin.Rotation);
            if (Pin.Image != null)
            {
                markerOptions.Anchor((float)Pin.Anchor.X, (float)Pin.Anchor.Y);
            }
        }
Exemplo n.º 28
0
        public void drawPins()
        {
            if (map != null)
            {
                map.Clear();

                if (customPins != null && customPins.Count > 0)
                {
                    var regularPinDescriptor = getRegularPinDescriptor();

                    if (regularPinDescriptor != null)
                    {
                        foreach (var pin in customPins)
                        {
                            var marker = new MarkerOptions();
                            marker.SetPosition(new LatLng(pin.pin.Position.Latitude, pin.pin.Position.Longitude));
                            marker.SetTitle(pin.pin.Label);
                            marker.SetSnippet(pin.pin.Address);
                            marker.SetIcon(regularPinDescriptor);

                            map.AddMarker(marker);
                        }

                        isDrawn = true;
                    }
                }
            }
        }
Exemplo n.º 29
0
        private void SetMarkers()
        {
            var customMap = Element as CustomMap;

            _markers = new List <Marker>();

            if (customMap.CustomPins == null)
            {
                return;
            }

            foreach (var customPin in customMap.CustomPins)
            {
                var marker = new MarkerOptions();

                marker.SetPosition(new LatLng(customPin.Pin.Position.Latitude, customPin.Pin.Position.Longitude));
                marker.SetTitle(customPin.Pin.Label);
                marker.SetSnippet(customPin.Pin.Address);

                var resource = typeof(Resource.Drawable).GetField(customPin.Image);

                if (resource != null)
                {
                    var resourceId = (int)resource.GetValue(customPin.Image);
                    marker.SetIcon(BitmapDescriptorFactory.FromResource(resourceId));
                    //_googleMap.SetOnMarkerClickListener(this);
                    _markers.Add(_googleMap.AddMarker(marker));
                }
            }
        }
        public async void OnMapReady(GoogleMap googleMap)
        {
            var location = await Geolocation.GetLastKnownLocationAsync();

            double defaultLatitude  = 45.768203;
            double defaultLongitude = 21.226415;

            if (location != null)
            {
                MarkerOptions markerOptions = new MarkerOptions();
                markerOptions.SetPosition(new LatLng(defaultLatitude, defaultLongitude));
                markerOptions.SetTitle("Pozitia mea");

                markerOptions.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueBlue));
                googleMap.AddMarker(markerOptions);
                googleMap.UiSettings.ZoomControlsEnabled = true;
                googleMap.MoveCamera(CameraUpdateFactory.NewLatLngZoom(markerOptions.Position, 14));
                var places = await GetNearByPlacesAsync(defaultLongitude, defaultLatitude);

                foreach (var place in places.results)
                {
                    MarkerOptions pharmacy = new MarkerOptions();
                    pharmacy.SetPosition(new LatLng(place.geometry.location.lat, place.geometry.location.lng));
                    pharmacy.SetTitle(place.name);
                    pharmacy.SetSnippet(place.vicinity);
                    googleMap.AddMarker(pharmacy);
                }
            }
        }