private async void setAdress(MarkerOptions pinMarker, GoogleMap.MapClickEventArgs e)
        {
            string adress = "";
            // Obtengo la posible dirección a partir de la latitud y longitud
            Geocoder geocoder = new Geocoder();
            IEnumerable<string> possibleAdresses = await geocoder.GetAddressesForPositionAsync(new Position(e.Point.Latitude, e.Point.Longitude));

            adress = possibleAdresses.ElementAt(0);
            pinMarker.SetTitle(adress);

            // Añado el pin al mapa
            _map.AddMarker(pinMarker).ShowInfoWindow();

            // Comparto el punto en App
            var myApp = App.Current as App;
            myApp.meetingPoint = new MeetingPoint
            {
                Name = adress,
                Place = new Position(e.Point.Latitude, e.Point.Longitude)
            };
        }
Esempio n. 2
0
        public MapRoute(GoogleMap map, List<Station> stations)
        {
            _map = map;
            _mapRoutes = new List<Polyline>();
            _mapStations = new List<Marker>();

            // Choose color;
            Color color = Color.DodgerBlue;

            // Create polyline.
            var polyline = new PolylineOptions();
            polyline.InvokeWidth(4f);
            polyline.InvokeColor(color);

            for (var i = 0; i < stations.Count; i++)
            {
                // Add points to polyline.
                var station = stations[i];
                if (station != null && station.latitude != 0f && station.longitude != 0f)
                {
                    var latlng = new Android.Gms.Maps.Model.LatLng(station.latitude, station.longitude);
                    polyline.Add(latlng);
                    // Create marker.
                    var marker = new MarkerOptions();
                    marker.SetPosition(latlng);
                    marker.SetTitle((i + 1) + ". " + station.postName);
                    marker.Draggable(false);
                    marker.SetSnippet("ul. " + station.street);
                    _mapStations.Add(_map.AddMarker(marker));
                }
            }

            // Add polyline to map.
            _mapRoutes.Add(_map.AddPolyline(polyline));
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.FirstView);

            var viewModel = (FirstViewModel) ViewModel;

            var mapFragment = (SupportMapFragment)SupportFragmentManager.FindFragmentById(Resource.Id.map);

            var options = new MarkerOptions();
            options.SetPosition(new LatLng(viewModel.Keith.Location.Lat, viewModel.Keith.Location.Lng));
            options.SetTitle("Keith");
            _keith = mapFragment.Map.AddMarker(options);

            var options2 = new MarkerOptions();
            options2.SetPosition(new LatLng(viewModel.Helen.Location.Lat, viewModel.Helen.Location.Lng));
            options2.SetTitle("Helen");
            _helen = mapFragment.Map.AddMarker(options2);

            var set = this.CreateBindingSet<FirstView, FirstViewModel>();
            set.Bind(_keith)
               .For(m => m.Position)
               .To(vm => vm.Keith.Location)
               .WithConversion(new LocationToLatLngValueConverter(), null);
            set.Bind(_helen)
               .For(m => m.Position)
               .To(vm => vm.Helen.Location)
               .WithConversion(new LocationToLatLngValueConverter(), null);
            set.Apply();

        }
Esempio n. 4
0
        protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged (sender, e);
            var androidMapView = (MapView)Control;
            var formsMap = (CustomMap)sender;

            if (e.PropertyName.Equals ("VisibleRegion") && !_isDrawnDone) {
                androidMapView.Map.Clear ();

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

                var formsPins = formsMap.CustomPins;

                foreach (var formsPin in formsPins) {
                    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.InvokeIcon (BitmapDescriptorFactory.FromAsset (String.Format ("{0}.png", formsPin.PinIcon)));
                    else
                        markerWithIcon.InvokeIcon (BitmapDescriptorFactory.DefaultMarker ());

                    androidMapView.Map.AddMarker (markerWithIcon);
                }

                _isDrawnDone = true;

            }
        }
Esempio n. 5
0
        // Function to add data fields passed on from Main Activity (Latitude, Longitude, Address - then adds a tag to marker utilising the address field if there's any)
        public void adddatatomap()
        {
            MarkerOptions opt = new MarkerOptions();
            double lat = Convert.ToDouble(Intent.GetStringExtra("Latitude"));
            double lng = Convert.ToDouble(Intent.GetStringExtra("Longitude"));
            string address = Intent.GetStringExtra("Address");

            LatLng location = new LatLng(lat, lng);

            opt.SetPosition(location);
            opt.SetTitle(address);

            map.AddMarker(opt); // Adds a marker to map based on the address that was past on from our Main Activity

            // Positioning the camera to show the marker based on fields parameter as set below
            CameraPosition.Builder builder = CameraPosition.InvokeBuilder();
            builder.Target(location);
            builder.Zoom(15);
            builder.Bearing(90);
            builder.Tilt(65);
            CameraPosition cameraPosition = builder.Build();
            CameraUpdate cameraUpdate = CameraUpdateFactory.NewCameraPosition(cameraPosition);

            map.MoveCamera(cameraUpdate);
            // Marker window clicked event
            map.InfoWindowClick += map_InfoWindowClick;
            // Marker dragged event
            map.MarkerDragEnd += map_MarkerDragEnd;
        }
        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);
            }
        }
		private void UpdatePins()
		{
			var androidMapView = (MapView)Control;
			var formsMap = (ExtendedMap)Element;

			androidMapView.Map.Clear ();

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

			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);
			}
		}
        public MapRenderer2Android()
            : base()
        {
            WireUpMap();

            MessagingCenter.Subscribe<IEnumerable<HeritageProperty>>(this, MapRenderer2.MESSAGE_ADD_AND_ZOOM_ON_PINS, async (items) =>
            {
                // wait for map
                await WaitForMap();
                   
                // loop all the properties and add them as markers
                foreach (var item in items)
                {
                    // create the marker
                    var m = new MarkerOptions();
                    m.SetPosition(new LatLng(item.Latitude, item.Longitude));
                    m.SetTitle(item.Name);

                    // add to map
                    this.NativeMap.AddMarker(m);
                }

                // zoom in on the pins
                ZoomAndCenterMap(items);
            });

            MessagingCenter.Subscribe<IEnumerable<HeritageProperty>>(this, MapRenderer2.MESSAGE_ZOOM_ON_PINS, (items) =>
            {
                // zoom in on the pins
                ZoomAndCenterMap(items);
            });
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.SecondView);

            var viewModel = (SecondViewModel) ViewModel;

            var mapFragment = (SupportMapFragment)SupportFragmentManager.FindFragmentById(Resource.Id.map);

            var options = new MarkerOptions();
            options.SetPosition(new LatLng(viewModel.Han.Location.Lat, viewModel.Han.Location.Lng));
            options.SetTitle("Han");
            options.Draggable(true);
            var hanMarker = mapFragment.Map.AddMarker(options);

            _han = new MarkerWrapper(hanMarker);

            mapFragment.Map.MarkerDragEnd += (sender, args) =>
                {
                    _han.FirePositionChangedFromMap();
                };

            var set = this.CreateBindingSet<SecondView, SecondViewModel>();
            set.Bind(_han)
               .For(m => m.Position)
               .To(vm => vm.Han.Location)
               .WithConversion(new LocationToLatLngValueConverter(), null);
            set.Apply();

        }
Esempio n. 10
0
 private void addEvent(net.cloudapp.geteventinfo.Eventas event1)
 {
     MarkerOptions marker = new MarkerOptions();
     marker.SetPosition(new LatLng(event1.latitude, event1.longitude));
     marker.SetTitle(event1.eventname);
     marker.SetSnippet(event1.description);
     marker.SetIcon(BitmapDescriptorFactory.FromAsset("f.png"));
     gMap.AddMarker(marker);
 }
Esempio n. 11
0
        public static List<MarkerOptions> FindCar()
        {
            List<MarkerOptions> markers = new List<MarkerOptions>();

            locationsFile = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
            locationsFile = Path.Combine(locationsFile, "locations.txt");

            IEnumerable<string> lines;

            if (File.Exists (locationsFile)) {
                lines = File.ReadLines (locationsFile);
            } else {
                return new List<MarkerOptions> ();
            }

            List<LocationRecord> records = new List<LocationRecord>();

            foreach (string line in lines ){
                LocationRecord record = JsonConvert.DeserializeObject<LocationRecord> (line);
                records.Add(record);
            }

            IEnumerable<string> speed = from record in records
                select record.calculatedSpeed > speedLimit ? "fast": "slow";
            string[] speeds = speed.ToArray();

            int i = 0;

            for(i=0; i<speeds.Count(); i++) {
                if (i > 0)
                {
                    if (speeds[i] != speeds[i - 1] && speeds[i] == "slow")
                    {
                        int fasts = CountFasts(speeds, i);
                        int slows = CountSlows(speeds, i);

                        long fastTime = records[i].unixTime - records[i-fasts].unixTime;
                        long slowTime = -( records[i].unixTime - records[i+slows].unixTime );

                        if (fastTime > millisBefore && slowTime > millisAfter && (DateTime.Now - records[i].time).TotalDays < 3)
                        {
                            MarkerOptions options = new MarkerOptions ();
                            options.SetPosition (new LatLng (records[i].latitude, records[i].longitude));
                            options.SetTitle (records[i].time.ToShortTimeString ());
                            options.SetSnippet (!double.IsNaN(records[i].recordedSpeed)?"Speed: " + String.Format ("{0:0.00}", records[i].recordedSpeed*3.6) + " km/h":"Speed: " + String.Format ("{0:0.00}", records[i].calculatedSpeed*3.6) + " km/h");
                            markers.Add(options);
                        }
                    }
                }
            }

            return markers;
        }
Esempio n. 12
0
        protected override void OnMapReady(GoogleMap map)
        {
            base.OnMapReady(map);
            var markerOptions = new Android.Gms.Maps.Model.MarkerOptions();

            markerOptions.SetTitle("Winffeeeeeeeeeee");
            markerOptions.SetPosition(new Android.Gms.Maps.Model.LatLng(37.051060, -122.014684));
            markerOptions.Draggable(true);
            myMarker = map.AddMarker(markerOptions);

            map.MarkerDrag      += Map_MarkerDrag;
            Map.PropertyChanged += Map_PropertyChanged;
        }
Esempio n. 13
0
		public void OnMapReady (GoogleMap googleMap)
		{
			gMap = googleMap;
			SetUpMapAllEvents ();
			gMap.MapLongClick += (object sender, GoogleMap.MapLongClickEventArgs e) => {

				MarkerOptions marker = new MarkerOptions();
				marker.SetPosition(new LatLng(e.Point.Latitude, e.Point.Longitude));
				marker.SetTitle("Kasis");
				marker.SetIcon(BitmapDescriptorFactory.DefaultMarker (BitmapDescriptorFactory.HueCyan));
                
				gMap.AddMarker(marker);
			};
		}
Esempio n. 14
0
        protected override void OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs<Xamarin.Forms.View> e)
        {
            base.OnElementChanged(e);

            extendedMap = (ExtendedMap)Element;
            mapView = Control as MapView;
            map = mapView.Map;

            map.MarkerClick+= HandleMarkerClick;

            // Pin tıklanınca sağalta açılan menüyü engellemek için
            map.UiSettings.MapToolbarEnabled = true;
            map.UiSettings.MyLocationButtonEnabled = true;

            if (extendedMap.isOverlayNeeded) {
                LatLng southwest = new LatLng (extendedMap.sw.Latitude, extendedMap.sw.Longitude);
                LatLng northeast = new LatLng (extendedMap.ne.Latitude, extendedMap.ne.Longitude);

                LatLngBounds bounds = new LatLngBounds (southwest, northeast);

                string url = extendedMap.overlayURL;//"http://www.mgm.gov.tr/mobile/mblhrt/data/radar/MAX--_6100_P00.png";

                Bitmap objBitmap = GetImageBitmapFromUrl (url);

                BitmapDescriptor objBitmapDescriptor = BitmapDescriptorFactory.FromBitmap (objBitmap);
                GroundOverlayOptions objGroundOverlayOptions = new GroundOverlayOptions ().PositionFromBounds (bounds)/*.Position (objMapPosition, 100000)*/.InvokeImage (objBitmapDescriptor);

                map.AddGroundOverlay (objGroundOverlayOptions);

                //For freeing memory
                objBitmap.Recycle ();
            }

            for (int i = 0; i < extendedMap.pinDatas.Count; i++) {
                var markerWithIcon = new MarkerOptions ();
                markerWithIcon.SetPosition (new LatLng (extendedMap.pinDatas[i].lat, extendedMap.pinDatas[i].lng));
                markerWithIcon.SetTitle (i.ToString());
                /*markerWithIcon.SetTitle ("aa");
                markerWithIcon.SetSnippet ("bb");*/
                int resID = Resources.GetIdentifier (extendedMap.pinDatas [i].icon, "drawable" , "com.app1001.bluemart");
                //System.Diagnostics.Debug.WriteLine (resID);
                markerWithIcon.SetIcon(BitmapDescriptorFactory.FromResource(resID));
                map.AddMarker (markerWithIcon);
            }

            //Add Pins

            //map.SetInfoWindowAdapter(this);
            map.UiSettings.RotateGesturesEnabled = false;
        }
        private void googleMap_MapClick(object sender, GoogleMap.MapClickEventArgs e)
        {
            ((MyBaseMap)Element).OnTap(new Position(e.Point.Latitude, e.Point.Longitude));

            // Borramos el anterior Pin
            _map.Clear();

            var pinMarker = new MarkerOptions();
            pinMarker.SetPosition(new LatLng(e.Point.Latitude, e.Point.Longitude));
            pinMarker.SetTitle("Punto de encuentro :)");
            pinMarker.DescribeContents();
            setAdress(pinMarker, e);

            // Añado el pin al mapa
            _map.AddMarker(pinMarker).ShowInfoWindow();
        }
Esempio n. 16
0
        public void adddatatomap()
        {
            LatLng loc0=new LatLng(-37.773250,175.250250);
            MarkerOptions opt0 = new MarkerOptions() //no semicolon
            .SetPosition(loc0)
            .SetRotation(45)

            .SetAlpha(.5f)
            .Draggable(true)
            .SetTitle("In the waikato")
            .SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.Icon))
            .SetSnippet("The presence of this actually creates an infowindow"); // which is why the other marker does not have one
            map.AddMarker(opt0);

            MarkerOptions opt1 = new MarkerOptions();
                double lat = Convert.ToDouble(Intent.GetStringExtra("Latitude"));
                double lng = Convert.ToDouble(Intent.GetStringExtra("Longitude"));
                string address = Intent.GetStringExtra("Address");

                LatLng location = new LatLng(lat, lng);

                opt1.SetPosition(location);
                opt1.SetTitle(address);

                map.AddMarker(opt1);

                // Positioning the camera to show the marker

                CameraPosition.Builder builder = CameraPosition.InvokeBuilder();
                builder.Target(location);
                builder.Zoom(15);
                builder.Bearing(90);
                builder.Tilt(65);
                CameraPosition cameraPosition = builder.Build();
                CameraUpdate cameraUpdate = CameraUpdateFactory.NewCameraPosition(cameraPosition);

                map.MoveCamera(cameraUpdate);
            //marker window clicked event
               map.InfoWindowClick += map_InfoWindowClick;
            //marker dragged event
                map.MarkerDragEnd += map_MarkerDragEnd;

               // map.SetInfoWindowAdapter(this);

            //  map.SetOnInfoWindowClickListener(this); //- implements the interface IOnInfoWindowclickListener
        }
    private void AddPin(ExtendedPin formsPin)
    {
      var androidMapView = (MapView) Control;

      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.InvokeIcon(BitmapDescriptorFactory.FromResource(GetResourceIdByName(formsPin.PinIcon)));
      }
      else
        markerWithIcon.InvokeIcon(BitmapDescriptorFactory.DefaultMarker());

      androidMapView.Map.AddMarker(markerWithIcon);
    }
		protected override void OnElementPropertyChanged (object sender, PropertyChangedEventArgs e)
		{
			base.OnElementPropertyChanged (sender, e);

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

				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;
			}
		}
        public static void PlaceMarkersOnTheMap(List<Feature> data, GoogleMap map)
        {
            foreach (var feature in data)
            {
                MarkerOptions wc = new MarkerOptions ();
                znajdzwc.Models.Geometry g = feature.geometry;
                Properties p = feature.properties;
                wc.SetPosition (new LatLng (g.coordinates [1], g.coordinates [0]));
                wc.SetTitle (p.name);
                wc.SetSnippet (p.comment);

                if(p.isFree)
                    wc.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.znajdz_wc_logo_free));
                else
                    wc.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.znajdz_wc_logo_free_money));

                map.AddMarker (wc);
            }
        }
		private void SetupMapIfNeeded()
		{
			if (_map == null)
			{
				_map = _mapFragment.Map;
				if (_map != null)
				{
					MarkerOptions marker1 = new MarkerOptions();
					marker1.SetPosition(VimyRidge);
					marker1.SetTitle("Vimy Ridge");
					_map.AddMarker(marker1);

					MarkerOptions marker2 = new MarkerOptions();
					marker2.SetPosition(Passchendaele);
					marker2.SetTitle("Passchendaele");
					_map.AddMarker(marker2);

					// We create an instance of CameraUpdate, and move the map to it.
					CameraUpdate cameraUpdate = CameraUpdateFactory.NewLatLngZoom(VimyRidge, 15);
					_map.MoveCamera(cameraUpdate);
				}
			}
		}
Esempio n. 21
0
		public void OnMapReady(GoogleMap googleMap)
		{
			globMap = googleMap;
            markerColor = new Dictionary<string, HamsterColor>();
			foreach ( var a in ViewModel.Markers) {
				var markerOpt = new MarkerOptions();
				double la = double.Parse(a.HamsterLatitude, System.Globalization.CultureInfo.InvariantCulture);
				double lon = double.Parse (a.HamsterLongitude, System.Globalization.CultureInfo.InvariantCulture);
				latlng = new LatLng (la, lon);
				markerOpt.SetPosition (latlng);
				markerOpt.SetTitle (String.Format("Name: {0} {1} ", a.FirstName, a.LastName));
				markerOpt.SetSnippet (String.Format("Latitude: {0}  Longitude: {1} ", a.HamsterLatitude, a.HamsterLongitude));
               
				globMap.AddMarker(markerOpt); 
                markerColor.Add(String.Format("{0}{1}",markerOpt.Title, markerOpt.Snippet), a.Color); 
			}
			globMap.MyLocationEnabled = true;
			globMap.UiSettings.CompassEnabled = true;
			globMap.UiSettings.MapToolbarEnabled = false;
			globMap.UiSettings.ZoomControlsEnabled = true;
			globMap.UiSettings.MyLocationButtonEnabled = false;

			globMap.SetInfoWindowAdapter (this);
		}
Esempio n. 22
0
        void CreateMarker()
        {
            var markerWithIcon = new MarkerOptions();

            var id = UIFileUtils.GetResourceIdFromFilename("pin.png");

            markerWithIcon.SetPosition(new LatLng(formsMap.MapPinLocation.Latitude, formsMap.MapPinLocation.Longitude));
            markerWithIcon.SetTitle("A blue pin");
            markerWithIcon.SetSnippet(string.Empty);

            markerWithIcon.SetIcon(BitmapDescriptorFactory.FromResource(id));
            map.MyLocationEnabled = formsMap.IsShowingUser;
            map.SetIndoorEnabled(false);

            try
            {
                map.AddMarker(markerWithIcon);
            }
            catch (NullPointerException ex)
            {
                System.Console.WriteLine("Exception : {0}--{1}", ex.Message, ex.InnerException);
            }
            isDrawnDone = true;
        }
Esempio n. 23
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);
     }
 }
Esempio n. 24
0
        private void OnMapClick(object sender, GoogleMap.MapClickEventArgs e)
        {
            var latlng = e.Point;
            // Create new destination marker.
            if (_destinationMarker == null)
            {
                var marker = new MarkerOptions();
                marker.SetPosition(latlng);
                marker.SetTitle("Do");
                marker.Draggable(true);
                marker.SetSnippet("Punkt docelowy");
                // TODO: Custom destination icon.

                _destinationMarker = _map.AddMarker(marker);
                _destinationMarker.ShowInfoWindow();
            }
            // Move existing marker.
            else
            {
                _destinationMarker.Position = latlng;
                _destinationMarker.ShowInfoWindow();
            }
        }
Esempio n. 25
0
        private void OnMyLocationButtonClick(object sender, GoogleMap.MyLocationButtonClickEventArgs e)
        {
            var myLocation = GetMyLocation();
            if (myLocation == null)
            {
                Logger.Log("Brak sygna³u GPS.");
                MessagingCenter.Send(_myMap, "DisplayAlert", new AlertMessage("B³¹d", "Brak sygna³u GPS."));
                return;
            }
            var myLatLng = new Android.Gms.Maps.Model.LatLng(myLocation.Latitude, myLocation.Longitude);

            // Create new starting marker.
            if (_startMarker == null)
            {
                var marker = new MarkerOptions();
                marker.SetPosition(myLatLng);
                marker.SetTitle("Od");
                marker.Draggable(true);
                // TODO: Custom start icon.

                _startMarker = _map.AddMarker(marker);
                _startMarker.ShowInfoWindow();
            }
            // Move existing marker.
            else
            {
                _startMarker.Position = myLatLng;
                _startMarker.ShowInfoWindow();
            }
            _map.AnimateCamera(CameraUpdateFactory.NewLatLngZoom(myLatLng, DefaultZoom));
        }
Esempio n. 26
0
                void UpdateMap(bool result)
                {
                    if (GroupEntries.Count > 0)
                    {
                        // update our list and display
                        SearchResultPrefix.Text = ConnectStrings.GroupFinder_Neighborhood;

                        (ListView.Adapter as GroupArrayAdapter).SetSelectedRow(0);

                        // for the map, ensure it's valid, because Google Play can fail
                        if (Map != null)
                        {
                            Map.Clear( );
                            MarkerList.Clear( );

                            Android.Gms.Maps.Model.LatLngBounds.Builder builder = new Android.Gms.Maps.Model.LatLngBounds.Builder();

                            // add the source position
                            Android.Gms.Maps.Model.MarkerOptions markerOptions = new Android.Gms.Maps.Model.MarkerOptions();
                            Android.Gms.Maps.Model.LatLng        pos           = new Android.Gms.Maps.Model.LatLng(SourceLocation.Latitude, SourceLocation.Longitude);
                            markerOptions.SetPosition(pos);
                            markerOptions.InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueGreen));
                            builder.Include(pos);

                            Android.Gms.Maps.Model.Marker marker = Map.AddMarker(markerOptions);
                            MarkerList.Add(marker);

                            for (int i = 0; i < GroupEntries.Count; i++)
                            {
                                // add the positions to the map
                                markerOptions = new Android.Gms.Maps.Model.MarkerOptions();
                                pos           = new Android.Gms.Maps.Model.LatLng(GroupEntries[i].Latitude, GroupEntries[i].Longitude);
                                markerOptions.SetPosition(pos);
                                markerOptions.SetTitle(GroupEntries[i].Name);
                                markerOptions.SetSnippet(string.Format("{0:##.0} {1}", GroupEntries[i].DistanceFromSource, ConnectStrings.GroupFinder_MilesSuffix));

                                builder.Include(pos);

                                marker = Map.AddMarker(markerOptions);
                                MarkerList.Add(marker);
                            }

                            Android.Gms.Maps.Model.LatLngBounds bounds = builder.Build( );

                            int paddingInPixels = Math.Min(View.Width, (int)(View.Height * .1f));

                            CameraUpdate camPos = CameraUpdateFactory.NewLatLngBounds(bounds, paddingInPixels);
                            Map.AnimateCamera(camPos);

                            // show the info window for the first (closest) group
                            MarkerList[1].ShowInfoWindow( );
                        }
                    }
                    else
                    {
                        if (result == true)
                        {
                            // send the analytic and update our list
                            SearchResultPrefix.Text       = ConnectStrings.GroupFinder_NoGroupsFound;
                            SearchResultNeighborhood.Text = string.Empty;

                            (ListView.Adapter as GroupArrayAdapter).SetSelectedRow(-1);

                            // validate the map before using. Google Play can error
                            if (Map != null)
                            {
                                // no groups found, so move the camera to the default position
                                Android.Gms.Maps.Model.LatLng defaultPos = new Android.Gms.Maps.Model.LatLng(ConnectConfig.GroupFinder_DefaultLatitude, ConnectConfig.GroupFinder_DefaultLongitude);
                                CameraUpdate camPos = CameraUpdateFactory.NewLatLngZoom(defaultPos, ConnectConfig.GroupFinder_DefaultScale_Android);
                                Map.AnimateCamera(camPos);
                            }
                        }
                        else
                        {
                            // there was actually an error. Let them know.
                            SearchResultPrefix.Text       = ConnectStrings.GroupFinder_NetworkError;
                            SearchResultNeighborhood.Text = string.Empty;
                        }
                    }
                }
Esempio n. 27
0
        private void OnBtnLocalizeClicked(MapPage mapPage)
        {
            var myLocation = GetMyLocation();
            if (myLocation == null)
            {
                Logger.Log("Brak sygna³u GPS.");
                MessagingCenter.Send(_myMap, "DisplayAlert", new AlertMessage("B³¹d", "Brak sygna³u GPS."));
                return;
            }
            var myLatLng = new Android.Gms.Maps.Model.LatLng(myLocation.Latitude, myLocation.Longitude);

            // Create new starting marker.
            if (_startMarker == null)
            {
                var marker = new MarkerOptions();
                marker.SetPosition(myLatLng);
                marker.SetTitle("Od");
                marker.Draggable(false);
                // TODO: Custom start icon.

                _startMarker = _map.AddMarker(marker);
                _startMarker.ShowInfoWindow();
            }
            // Move existing marker.
            else
            {
                _startMarker.Position = myLatLng;
            }
            _map.AnimateCamera(CameraUpdateFactory.NewLatLngZoom(myLatLng, DefaultZoom));

            // TODO: Display nearest stations.
            var nearestStations = App.Database.GetNearestStations(myLatLng.Latitude, myLatLng.Longitude, 5);
            for (var i = 0; i < nearestStations.Length; i++)
            {
                var station = nearestStations[i];
                var marker = new MarkerOptions();
                var latLng = new Android.Gms.Maps.Model.LatLng(station.latitude, station.longitude);
                marker.SetPosition(latLng);
                marker.SetTitle(string.Format("{0}. {1} - {2}", station.postId, station.postName, station.street));
                marker.Draggable(false);
                marker.SetSnippet("Wiêcej...");
                // TODO: Custom stations's icon.

                var mapMarker = _map.AddMarker(marker);
                var stationMarker = new StationMarker(station, mapMarker);
                _nearestMarkers.Add(stationMarker);
            }
        }
Esempio n. 28
0
		public void AddMarkers ()
		{
			GoogleMap map = mapFragment.Map;
			if (map != null) {
				map.Clear ();
				if (LoginState.ActiveUser != null) {
					foreach (var item in LoginState.ActiveUser.AccessInfo) {
						var tokens = item.Location.Split (new char[] {' '}, System.StringSplitOptions.RemoveEmptyEntries);
						if (tokens.Length >= 2) {
							double lat = double.NaN;
							double.TryParse (tokens [0], out lat);
							double lng = double.NaN;
							double.TryParse (tokens [1], out lng);
							if (lat != double.NaN && lng != double.NaN) {
								LatLng location = new LatLng (lat, lng);
								var marker = new MarkerOptions ();
								marker.SetPosition (location);
								marker.SetTitle (item.Name);
								marker.SetSnippet ("Free slots: " + item.Spots);

								Bitmap b = BitmapFactory.DecodeResource (Resources, Resource.Drawable.map_tag);
								Bitmap bhalfsize = Bitmap.CreateScaledBitmap (b, b.Width / 3, b.Height / 3, false);

								marker.InvokeIcon (BitmapDescriptorFactory.FromBitmap (bhalfsize));
								marker.Flat (false);

								map.AddMarker (marker);
							}
						}
					}
				}
			}
		}
Esempio n. 29
0
		MarkerOptions GetMarkerOptionsForAssignment (Assignment assignment)
		{
			var markerOptions = new MarkerOptions ();
			markerOptions.SetPosition (new LatLng (assignment.Latitude, assignment.Longitude));
			markerOptions.SetTitle (assignment.CompanyName);
			markerOptions.SetSnippet (string.Format ("{0} {1}, {2} {3}",
				assignment.Address, assignment.City, assignment.State, assignment.Zip));
			
			return markerOptions;
		}
        /// <summary>
        /// Adds a marker to the map
        /// </summary>
        /// <param name="pin">The Forms Pin</param>
        private async void AddPin(TKCustomMapPin pin)
        {
            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);

            this._markers.Add(pin, this._googleMap.AddMarker(markerWithIcon));
        }
Esempio n. 31
0
        private void updatePins()
        {
            var androidMapView = (MapView)Control;
            var formsMap = (Xam.Plugin.MapExtend.Abstractions.MapExtend)Element;

            androidMapView.Map.Clear();


            androidMapView.Map.MyLocationEnabled = formsMap.IsShowingUser;


            var items = formsMap.Pins;

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

                markerWithIcon.Draggable(true);

                androidMapView.Map.AddMarker(markerWithIcon);
            }
        }
Esempio n. 32
0
        void DrawRunTrack(bool mapShouldFollow)
        {
            if (mRunLocations.Count < 1)
                return;
            // Set up overlay for the map with the current run's locations
            // Create a polyline with all of the points
            PolylineOptions line = new PolylineOptions();
            // Create a LatLngBounds so you can zoom to fit
            LatLngBounds.Builder latLngBuilder = new LatLngBounds.Builder();
            // Add the locations of the current run
            foreach (RunLocation loc in mRunLocations) {
                LatLng latLng = new LatLng(loc.Latitude, loc.Longitude);
                line.Add(latLng);
                latLngBuilder.Include(latLng);
            }
            // Add the polyline to the map
            mGoogleMap.AddPolyline(line);

            // Add markers
            LatLng startLatLng = new LatLng(mRunLocations[0].Latitude, mRunLocations[0].Longitude);
            MarkerOptions startMarkerOptions = new MarkerOptions();
            startMarkerOptions.SetPosition(startLatLng);
            startMarkerOptions.SetTitle(Activity.GetString(Resource.String.run_start));
            startMarkerOptions.SetSnippet(Activity.GetString(Resource.String.run_started_at_format, new Java.Lang.Object[]{new Java.Lang.String(mRunLocations[0].Time.ToLocalTime().ToLongTimeString())}));
            mGoogleMap.AddMarker(startMarkerOptions);

            var activeRun = mRunManager.GetActiveRun();

            if (activeRun == null || (activeRun != null && CurrentRun.Id != activeRun.Id)) {
                LatLng stopLatLng = new LatLng(mRunLocations[mRunLocations.Count-1].Latitude, mRunLocations[mRunLocations.Count-1].Longitude);
                MarkerOptions stopMarkerOptions = new MarkerOptions();
                stopMarkerOptions.SetPosition(stopLatLng);
                stopMarkerOptions.SetTitle(Activity.GetString(Resource.String.run_finish));
                stopMarkerOptions.SetSnippet(Activity.GetString(Resource.String.run_finished_at_format, new Java.Lang.Object[]{new Java.Lang.String(mRunLocations[mRunLocations.Count-1].Time.ToLocalTime().ToLongTimeString())}));
                mGoogleMap.AddMarker(stopMarkerOptions);
            }

            // Make the map zoom to show the track, with some padding
            // Use the size of the map linear layout in pixels as a bounding box
            LatLngBounds latLngBounds = latLngBuilder.Build();
            // Construct a movement instruction for the map
            CameraUpdate movement = CameraUpdateFactory.NewLatLngBounds(latLngBounds, mMapWidth, mMapHeight, 50);
            if (mMapShouldFollow) {
                try {
                    mGoogleMap.MoveCamera(movement);
                    mMapShouldFollow = mapShouldFollow;
                }
                catch (Exception ex) {
                    Console.WriteLine("[{0}] No Layout yet {1}", TAG, ex.Message);
                }
            }
        }