Beispiel #1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            button = FindViewById<Button>(Resource.Id.GetLocationButton);
            latitude = FindViewById<TextView>(Resource.Id.LatitudeText);
            longitude = FindViewById<TextView>(Resource.Id.LongitudeText);
            provider = FindViewById<TextView>(Resource.Id.ProviderText);
            address = FindViewById<TextView>(Resource.Id.AddressText);

            // MapFragment の用意と初期の場所を指定します。
            // MapFragment.Map が deprecated みたいなので、正しい書き方を教えてください><
            MapFragment mapFrag = (MapFragment)FragmentManager.FindFragmentById(Resource.Id.MapFragment);
            map = mapFrag.Map;
            if (map != null) // Map の準備が出来たら (最初は null を返します)
            {
                map.MyLocationEnabled = true; // 現在地ボタン オン
                map.UiSettings.ZoomControlsEnabled = true; // ズームコントロール オン
                // 初期位置(カメラ)を移動
                map.AnimateCamera(CameraUpdateFactory.NewCameraPosition(
                    new CameraPosition(
                        new LatLng(35.685344d, 139.753029d), // 皇居(中心位置)
                        12f, 0f, 0f))); // ズームレベル、方位、傾き
            }
        }
		void FindMap ()
		{
			_map = (SupportFragmentManager.FindFragmentById (Resource.Id.map) as SupportMapFragment).Map;
			if (_map != null) {
				_map.MyLocationEnabled = true;

				_map.UiSettings.TiltGesturesEnabled = false;
				_map.UiSettings.RotateGesturesEnabled = false;

				_map.MapClick += OnMapClick;
				_map.MapLongClick += OnMapLongClick;
				_map.MyLocationChange += HandleMyLocationChange;
				_map.MarkerClick += OnMarkerClick;

				_map.SetInfoWindowAdapter (new InfoWindowAdapter ());

				// here because map should be already initialized
				// http://developer.android.com/reference/com/google/android/gms/maps/model/BitmapDescriptorFactory.html
				_alarm_marker_normal = BitmapDescriptorFactory.FromResource (Resource.Drawable.marker_violet);
				_alarm_marker_normal_selected = BitmapDescriptorFactory.FromResource (Resource.Drawable.marker_violet_selected);
				_alarm_marker_disabled_selected = BitmapDescriptorFactory.FromResource (Resource.Drawable.marker_grey_selected);				
				_alarm_marker_disabled = BitmapDescriptorFactory.FromResource (Resource.Drawable.marker_grey);
                
				RefreshData ();

				_map.SetOnMapLoadedCallback (this);

				if (Mode == Mode.Add) {
					if (AlarmToAddMarker != null) {
						AlarmToAddMarker = _map.AddMarker (new MarkerOptions ().SetPosition (AlarmToAddMarker.Position).InvokeIcon (_alarm_marker_normal));
					}
				}
			}
		}
Beispiel #3
0
        protected override void OnMapReady(Android.Gms.Maps.GoogleMap map)
        {
            //base.OnMapReady(map);

            myMap = map;
            Position pos = new Position();

            /*   // object of referemce is not se to an instance of an object
             * pos = new Position(circle.Position.Latitude , circle.Position.Longitude);
             * var circleOptions = new CircleOptions();
             * circleOptions.InvokeCenter(new LatLng(pos.Latitude, pos.Longitude));
             * circleOptions.InvokeRadius(circle.Radius);
             * circleOptions.InvokeFillColor(0X66FF0000);
             * circleOptions.InvokeStrokeColor(0X66FF0000);
             * circleOptions.InvokeStrokeWidth(0);
             *
             * myMap.AddCircle(circleOptions);
             *
             *
             * var position = new Position(37.79752, -122.40183);
             * /*  myMap.AddCircle = new CustomCircle
             * {
             *     Position = position,
             *     Radius = 1000
             * };  */
        }
        public void OnMapReady(GoogleMap map)
        {
            googleMap = map;
            googleMap.UiSettings.CompassEnabled = false;
            googleMap.UiSettings.MyLocationButtonEnabled = false;
            googleMap.UiSettings.MapToolbarEnabled = false;

            if (googleMap == null)
                return;

            googleMap.Clear ();

            try {
                MapsInitializer.Initialize (this);
            } catch (GooglePlayServicesNotAvailableException e) {
                Console.WriteLine ("Google Play Services not available:" + e);
                return;
            }

            if (assignment == null)
                return;

            var markerOptions = GetMarkerOptionsForAssignment (assignment);
            googleMap.AddMarker (markerOptions).ShowInfoWindow ();
            googleMap.CameraPosition.Target = markerOptions.Position;

            googleMap.MoveCamera (CameraUpdateFactory.NewLatLngZoom (markerOptions.Position, 15f));
        }
Beispiel #5
0
 /* End ILocationListener interfaces */
 /// <summary>
 /// IOnMapReadyCallback interface
 /// </summary>
 /// <param name="map">Map.</param>
 public void OnMapReady(GoogleMap map)
 {
     Log.Info ("Map", "ready");
     this.map = map;
     if (lastKnownLocation != null && !ready)
         ReadyForLocationMap ();
 }
		void CargamosMarcadores ()
		{
			if (mMap == null) 
			{
				mMap = _mapFragment.Map;
				if (mMap != null)
				{
					//Relizamos un ciclo para cargar todas las ciudades en nuestro mapa y le asignamos un puntero de color azul
					foreach (Ciudad_Marca ciudad in MisCiudades) 
					{
						ciudad.Marcador=mMap.AddMarker(new MarkerOptions()
						                               .SetPosition(ciudad.Ubicacion)
						                               .SetTitle(ciudad.Nombre)
						                               .SetSnippet(ciudad.Descripcion)
						                               .InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueAzure)));
					}

					//Le indicamos que deve de cargar un ventana de información personalizada 
					mMap.SetInfoWindowAdapter (new CustomInfoWindowAdapter (this,MisCiudades));

					//Ubicamos la cámara en un posición que se puedan ver las marcas 
					mMap.MoveCamera(CameraUpdateFactory.NewLatLngZoom(new LatLng ( 21.12806,-101.689163), 6));

				}

			}
		}
Beispiel #7
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));
        }
        public void OnMapReady(GoogleMap googleMap)
        {
            _map = googleMap;

            if (_map != null)
                _map.MapClick += googleMap_MapClick;
        }
Beispiel #9
0
        async void drawMark(string type, GeoPoint point)
        {
            MapFragment mapFrag = (MapFragment)FragmentManager.FindFragmentById(Resource.Id.map);

            Android.Gms.Maps.GoogleMap map = mapFrag.Map;
            Marker        marker;
            MarkerOptions markerOptions;

            switch (type)
            {
            case "origin":
                markerOptions = new MarkerOptions();
                markerOptions.SetPosition(new LatLng(point.latitude, point.longitude));
                markerOptions.SetTitle("Origin");
                marker = map.AddMarker(markerOptions);
                marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.car));
                break;

            case "finalDestionation":
                markerOptions = new MarkerOptions();
                markerOptions.SetPosition(new LatLng(point.latitude, point.longitude));
                markerOptions.SetTitle("Final Destination");
                marker = map.AddMarker(markerOptions);
                marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.CheckeredFlag));
                break;

            case "pitStop":
                markerOptions = new MarkerOptions();
                markerOptions.SetPosition(new LatLng(point.latitude, point.longitude));
                markerOptions.SetTitle("Final Destination");
                marker = map.AddMarker(markerOptions);
                break;
            }
        }
Beispiel #10
0
 public void OnMapReady(GoogleMap googleMap)
 {
     map = googleMap;
     map.UiSettings.MyLocationButtonEnabled = false;
     map.UiSettings.ZoomControlsEnabled = false;
     CreateMarker();
 }
		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;

			// 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));
			_map.AddMarker(marker2);

			// Add custom marker images on the map
			AddMonkeyMarkersToMap();

			// Add custom arrow callout on map
			AddInitialNewYorkBarToMap();

			// 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?");
			}

			// TODO: Step 4a - attach map handler for marker touch
//            _map.MarkerClick += MapOnMarkerClick;

			// TODO: Step 4c - attach map handler for info window touch
//			_map.InfoWindowClick += HandleInfoWindowClick;
		}
        public void OnMapReady (GoogleMap googleMap)
        {
            map = googleMap;

            map.UiSettings.ZoomControlsEnabled = false;

            map.MoveCamera (CameraUpdateFactory.NewLatLngZoom (new LatLng (-33.87365, 151.20689), 10));
        }
Beispiel #13
0
 protected override void OnMapReady(Android.Gms.Maps.GoogleMap map)
 {
     map.MapClick += Map_MapClick;
     NativeMap.InfoWindowClick += OnInfoWindowClick;
     NativeMap.SetInfoWindowAdapter(this);
     drawMarkers(150);
     base.OnMapReady(map);
 }
Beispiel #14
0
        public void OnMapReady(GoogleMap googleMap)
        {
            this.googleMap = googleMap;

            LatLng denmarkLatLng = new LatLng(56, 10.5);
            googleMap.MoveCamera(CameraUpdateFactory.NewLatLng(denmarkLatLng));
            googleMap.AnimateCamera(CameraUpdateFactory.ZoomTo(6));
        }
 public void OnMapReady (GoogleMap googleMap)
 {
     map = googleMap;
     updateTraffic ();
     updateMyLocation ();
     updateBuildings ();
     updateIndoor ();
 }
 protected override void OnMapReady(Android.Gms.Maps.GoogleMap map)
 {
     base.OnMapReady(map);
     this.map = map;
     map.SetOnMarkerDragListener(new markerListenerDrag(this));
     map.UiSettings.ZoomControlsEnabled     = false;
     map.UiSettings.MyLocationButtonEnabled = false;
 }
Beispiel #17
0
        protected override void OnMapReady(Android.Gms.Maps.GoogleMap map)
        {
            base.OnMapReady(map);
            Log.Debug("GoogleMap Ready");
            mapReady       = true;
            this.googleMap = map;

            Draw();
        }
 protected override void OnMapReady(Android.Gms.Maps.GoogleMap map)
 {
     //map.
     if (trackMapContext.IsShowConnectedRoutePointsLines)
     {
         drawConnectedLines();
     }
     base.OnMapReady(map);
 }
		public void OnMapReady (GoogleMap map)
		{
			googleMap = map;
			googleMap.UiSettings.CompassEnabled = false;
			googleMap.UiSettings.MyLocationButtonEnabled = false;
			googleMap.UiSettings.MapToolbarEnabled = false;

			UpdateLocations ();
		}
        public void OnMapReady(GoogleMap googleMap)
        {
            Map = googleMap;

            var handler = MapReady;

            if (handler != null)
                handler (this, EventArgs.Empty);
        }
Beispiel #21
0
		public void OnMapReady(GoogleMap googleMap)
		{
//			googleMap.MyLocationEnabled = true;
			googleMap.UiSettings.ZoomControlsEnabled = false;
			googleMap.UiSettings.MyLocationButtonEnabled = false;
			googleMap.UiSettings.ScrollGesturesEnabled = true;
			googleMap.UiSettings.ZoomGesturesEnabled = true;
			googleMap.UiSettings.CompassEnabled = true;
			googleMap.UiSettings.MapToolbarEnabled = false;
		}
        public void OnMapReady(GoogleMap googleMap)
        {
            this.googleMap = googleMap;

            this.googleMap.UiSettings.CompassEnabled = false;
            this.googleMap.UiSettings.MyLocationButtonEnabled = false;
            this.googleMap.UiSettings.MapToolbarEnabled = false;

            MapsInitializer.Initialize (this.Context);

            this.MoveToRegion (((LiteMap)this.Element).VisibleRegion, false);
        }
 public void OnMapReady (GoogleMap googleMap)
 {
     googleMap.MarkerDragEnd += (sender, e) => {
         mStreetViewPanorama.SetPosition (e.Marker.Position, 150);
     };
                         
     // Creates a draggable marker. Long press to drag.
     mMarker = googleMap.AddMarker (new MarkerOptions()
         .SetPosition (markerPosition)
         .SetIcon (BitmapDescriptorFactory.FromResource (Resource.Drawable.pegman))
         .Draggable(true));
 }
		public void OnMapReady (GoogleMap googleMap)
		{
			map = googleMap;

			var circleOptions = new CircleOptions ();
			circleOptions.InvokeCenter (new LatLng (circle.Position.Latitude, circle.Position.Longitude));
			circleOptions.InvokeRadius (circle.Radius);
			circleOptions.InvokeFillColor (0X66FF0000);
			circleOptions.InvokeStrokeColor (0X66FF0000);
			circleOptions.InvokeStrokeWidth (0);
			map.AddCircle (circleOptions);
		}
		/**
     * Sets up the map if it is possible to do so (i.e., the Google Play services APK is correctly
     * installed) and the map has not already been instantiated.. This will ensure that we only ever
     * call {@link #setUpMap()} once when {@link #mMap} is not null.
     * <p>
     * If it isn't installed {@link SupportMapFragment} (and
     * {@link com.google.android.gms.maps.MapView
     * MapView}) will show a prompt for the user to install/update the Google Play services APK on
     * their device.
     * <p>
     * A user can return to this Activity after following the prompt and correctly
     * installing/updating/enabling the Google Play services. Since the Activity may not have been
     * completely destroyed during this process (it is likely that it would only be stopped or
     * paused), {@link #onCreate(Bundle)} may not be called again so we should call this method in
     * {@link #onResume()} to guarantee that it will be called.
     */
		private void SetUpMapIfNeeded() 
		{
			// Do a null check to confirm that we have not already instantiated the map.
			if (mMap == null) {
				// Try to obtain the map from the SupportMapFragment.
				mMap = ((SupportMapFragment) SupportFragmentManager.FindFragmentById (Resource.Id.map)).Map;
				// Check if we were successful in obtaining the map.
				if (mMap != null) {
					SetUpMap ();
				}
			}
		}
        protected override void OnStop()
        {
            if (_map != null)
            {
                _selectedMarker = null;
                _map.Clear();
            }

            _map = null;

            base.OnStop();
        }
Beispiel #27
0
		void GoogleMap_MyLocationChange (object sender, GoogleMap.MyLocationChangeEventArgs e)
		{
			behavior.UserLocation = new Position(
				e.Location.Latitude,
				e.Location.Longitude);

			// なぜかCameraChangeにハンドラを追加するとXF.Maps.Map.VisibleRegionが更新されなくなるので、暫定的にここで対処
			var position = googleMap.CameraPosition;
			XFAedSearch.Droid.Helpers.Settings.Latitude = position.Target.Latitude;
			XFAedSearch.Droid.Helpers.Settings.Longitude = position.Target.Longitude;
			XFAedSearch.Droid.Helpers.Settings.ZoomLevel = position.Zoom;
		}
 public void OnMapReady (GoogleMap googleMap)
 {
     googleMap.MapClick += (sender, e) => {
         tapTextView.Text = "Tapped: Point=" + e.Point;
     };
     googleMap.MapLongClick += (sender, e) => {
         tapTextView.Text = "Long Pressed: Point=" + e.Point;
     };
     googleMap.CameraChange += (sender, e) => {
         cameraTextView.Text = e.Position.ToString ();
     };
 }
        protected override void OnStart()
        {
            base.OnStart();

            _map = (SupportFragmentManager.FindFragmentById(Resource.Id.map) as SupportMapFragment).Map;

            if (_map != null)
            {
                _map.MyLocationEnabled = true;

                RedrawAlarm();
            }
        }
		public void OnMapReady (GoogleMap googleMap)
		{
			map = googleMap;

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

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

			map.AddPolyline (polylineOptions);
		}
Beispiel #31
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;
        }
        void Map_MarkerClick(object sender, GoogleMap.MarkerClickEventArgs e)
        {
            var marker = e.Marker;
            var mapTile = (MapTile)Element;

            var newCamera = CameraUpdateFactory.NewLatLng(marker.Position);
            var moveCallBack = new MoveCallback();
            moveCallBack.Finishing += (ss, ee) => 
            {
                if (marker.Snippet != CurrentLocationSnippet)
                    mapTile.ShowPinDetailInfo(marker.Snippet);
            };
            NativeMap.AnimateCamera(newCamera, 200, moveCallBack);
        }
		void OnInfoWindowClick (object sender, GoogleMap.InfoWindowClickEventArgs e)
		{
			var customPin = GetCustomPin (e.Marker);
			if (customPin == null) {
				throw new Exception ("Custom pin not found");
			}

			if (!string.IsNullOrWhiteSpace (customPin.Url)) {
				var url = Android.Net.Uri.Parse (customPin.Url);
				var intent = new Intent (Intent.ActionView, url);
				intent.AddFlags (ActivityFlags.NewTask);
				Android.App.Application.Context.StartActivity (intent);
			}
		}
Beispiel #34
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Main);

            // Start 'GPS'
            InitializeLocationManager ();

            // Setup 'Google Maps'
            mapFrag = (MapFragment) FragmentManager.FindFragmentById(Resource.Id.map);
            map = mapFrag.Map;
        }
Beispiel #35
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);
			};
		}
 /// <summary>
 /// Raises the map ready event.
 /// </summary>
 /// <param name="googleMap">Google map.</param>
 public void OnMapReady(GoogleMap googleMap)
 {
     this.Map = googleMap;
     this.AddFields();
     this.Map.MapClick += this.MapClicked;
     this.Map.MyLocationEnabled = true;
     this.Map.UiSettings.MyLocationButtonEnabled = true;
     this.Map.MyLocationChange += this.SetUserPositionOnce;
     var handler = this.MapReady;
     if (handler != null)
     {
         handler(this, EventArgs.Empty);
     }
 }
Beispiel #37
0
        protected override void OnMapReady(Android.Gms.Maps.GoogleMap map)
        {
            base.OnMapReady(map);

            var polylineOptions = new PolylineOptions();

            polylineOptions.InvokeColor(-16776961);
            polylineOptions.InvokeWidth(20);

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

            NativeMap.AddPolyline(polylineOptions);
        }
Beispiel #38
0
        protected override void OnMapReady(Android.Gms.Maps.GoogleMap map)
        {
            base.OnMapReady(map);

            var polygonOptions = new PolygonOptions();

            polygonOptions.InvokeFillColor(0x66FF0000);
            polygonOptions.InvokeStrokeColor(0x660000FF);
            polygonOptions.InvokeStrokeWidth(30.0f);

            foreach (var position in shapeCoordinates)
            {
                polygonOptions.Add(new LatLng(position.Latitude, position.Longitude));
            }
            NativeMap.AddPolygon(polygonOptions);
        }
Beispiel #39
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);

            _addressText  = FindViewById <TextView>(Resource.Id.address_text);
            _locationText = FindViewById <TextView>(Resource.Id.location_text);
            FindViewById <TextView>(Resource.Id.search_gas_button).Click += SearchGas_OnClick;

            List <Place> places = new List <Place> ();

            markers = new List <Marker> ();

            Algorithm            algorithm = new Algorithm();
            Task <List <Place> > result    = Task.Run(() => algorithm.Run());

            Task.WaitAll(result);
            places = result.Result;

            markPlaces(places);

            MapFragment mapFrag = (MapFragment)FragmentManager.FindFragmentById(Resource.Id.map);

            Android.Gms.Maps.GoogleMap map = mapFrag.Map;
            map.MarkerClick += MapMarkerClick;


            GeoPoint origin               = Algorithm.getCurrentLocation();
            GeoPoint endPoint             = Algorithm.getFinalDestination();
            string   transportationMethod = "driving";

            Task <TravelData> result2 = Task.Run(() => algorithm.getOriginalRoute(transportationMethod, origin, endPoint));

            originalRoute = result2.Result;

            Task <TravelData> result3      = Task.Run(() => algorithm.getPitStopRoute(transportationMethod, origin, places[1].Location, endPoint));
            TravelData        pitStopRoute = result3.Result;

            polyLines = new List <Polyline> ();

            drawMark("origin", origin);
            drawMark("finalDestionation", endPoint);
            drawRoute(originalRoute, true);

            InitializeLocationManager();
        }
Beispiel #40
0
        async void SearchGas_OnClick(object sender, EventArgs eventArgs)
        {
            if (_currentLocation == null)
            {
                _addressText.Text = "Location is null";
                return;
            }

            Algorithm algorithm = new Algorithm();

            GeoPoint currentLoc  = new GeoPoint(_currentLocation.Latitude, _currentLocation.Longitude);
            GeoPoint destination = Algorithm.getFinalDestination();

            TravelData currentRoute = await algorithm.getOriginalRoute("driving", currentLoc, destination);

            List <GeoPoint> pointsToSearch = algorithm.findPointsToSearch(currentRoute, 500, currentLoc);

            MapFragment mapFrag = (MapFragment)FragmentManager.FindFragmentById(Resource.Id.map);

            Android.Gms.Maps.GoogleMap map = mapFrag.Map;

            foreach (GeoPoint point in pointsToSearch)
            {
                MarkerOptions markerOpt1 = new MarkerOptions();
                markerOpt1.SetPosition(new LatLng(point.latitude, point.longitude));
                markerOpt1.SetTitle("Test Marker");
                map.AddMarker(markerOpt1);

                CircleOptions circleOptions = new CircleOptions();
                circleOptions.InvokeCenter(new LatLng(point.latitude, point.longitude));
                circleOptions.InvokeRadius(500);
                map.AddCircle(circleOptions);
            }

            LatLng location2 = new LatLng(pointsToSearch[3].latitude, pointsToSearch[7].longitude);

            CameraPosition.Builder builder = CameraPosition.InvokeBuilder();
            builder.Target(location2);
            builder.Zoom(12);
            //builder.Bearing(155);
            //builder.Tilt(65);
            CameraPosition cameraPosition = builder.Build();
            CameraUpdate   cameraUpdate   = CameraUpdateFactory.NewCameraPosition(cameraPosition);

            map.MoveCamera(cameraUpdate);
        }
Beispiel #41
0
        async void drawRoute(TravelData route, bool isOriginalRoute)
        {
            MapFragment mapFrag = (MapFragment)FragmentManager.FindFragmentById(Resource.Id.map);

            Android.Gms.Maps.GoogleMap map = mapFrag.Map;

            // DRAW THE ORIGIN POINT FIRST, THEN POLYLINE, ENDPOINT, POLYLINE, ENDPOINT...
            PolylineOptions polylineOptions = new PolylineOptions();

            polylineOptions.Add(new LatLng(route.steps [0].originXY.latitude, route.steps [0].originXY.longitude));
            Polyline polyline = map.AddPolyline(polylineOptions);

            if (isOriginalRoute)
            {
                polyline.Color = Resources.GetColor(Resource.Color.wallet_holo_blue_light);
            }
            else
            {
                polyline.Color = Resources.GetColor(Resource.Color.abc_search_url_text_pressed);
            }
            polyline.Width = 15;
            polyLines.Add(polyline);

            foreach (Step step in route.steps)
            {
                polylineOptions = new PolylineOptions();

                List <GeoPoint> stepPoints = Algorithm.decodePoints(step.polyLine);
                foreach (GeoPoint point in stepPoints)
                {
                    polylineOptions.Add(new LatLng(point.latitude, point.longitude));
                }
                polylineOptions.Add(new LatLng(step.endpointXY.latitude, step.endpointXY.longitude));
                polyline = map.AddPolyline(polylineOptions);
                if (isOriginalRoute)
                {
                    polyline.Color = Resources.GetColor(Resource.Color.wallet_holo_blue_light);
                }
                else
                {
                    polyline.Color = Resources.GetColor(Resource.Color.abc_search_url_text_pressed);
                } polyline.Width = 15;
                polyLines.Add(polyline);
            }
        }
Beispiel #42
0
        protected override void Dispose(bool disposing)
        {
            if (disposing && !_disposed)
            {
                _disposed = true;
                Uninitialize(NativeMap, Map);

                if (NativeMap != null)
                {
                    NativeMap.Dispose();
                    NativeMap = null;
                }

                (Control as MapView)?.OnDestroy();
            }

            base.Dispose(disposing);
        }
Beispiel #43
0
        private void Uninitialize(Android.Gms.Maps.GoogleMap nativeMap, Map map)
        {
            try
            {
                if (nativeMap == null)
                {
                    System.Diagnostics.Debug.WriteLine($"Uninitialize failed - {nameof(nativeMap)} is null");
                    return;
                }

                if (map == null)
                {
                    System.Diagnostics.Debug.WriteLine($"Uninitialize failed - {nameof(map)} is null");
                    return;
                }

                _uiSettingsLogic.Unregister();

                map.OnSnapshot -= OnSnapshot;
                _cameraLogic.Unregister();

                foreach (var logic in _logics)
                {
                    logic.Unregister(nativeMap, map);
                }
                if (Map.IsUseCluster)
                {
                    _clusterLogic.Unregister(nativeMap, map);
                }

                nativeMap.SetOnMapClickListener(null);
                nativeMap.SetOnMapLongClickListener(null);
                nativeMap.SetOnMyLocationButtonClickListener(null);

                nativeMap.MyLocationEnabled = false;
                nativeMap.Dispose();
            }
            catch (System.Exception ex)
            {
                var message = ex.Message;
                System.Diagnostics.Debug.WriteLine($"Uninitialize failed. - {message}");
            }
        }
Beispiel #44
0
        protected override void OnMapReady(Android.Gms.Maps.GoogleMap map)
        {
            base.OnMapReady(map);

            if (circle == null)
            {
                return;
            }

            var circleOptions = new CircleOptions();

            circleOptions.InvokeCenter(new LatLng(circle.Position.Latitude, circle.Position.Longitude));
            circleOptions.InvokeRadius(circle.Radius);
            circleOptions.InvokeFillColor(0X66FF0000);
            circleOptions.InvokeStrokeColor(0X66FF0000);
            circleOptions.InvokeStrokeWidth(0);

            NativeMap.AddCircle(circleOptions);
        }
        protected override void OnMapReady(Android.Gms.Maps.GoogleMap map)
        {
            base.OnMapReady(map);

            var polylineOptions = new PolylineOptions();

            polylineOptions.InvokeColor(0x66FF0000);

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

            NativeMap.AddPolyline(polylineOptions);
            NativeMap.UiSettings.ZoomControlsEnabled     = false;
            NativeMap.UiSettings.ZoomGesturesEnabled     = true;
            NativeMap.UiSettings.MyLocationButtonEnabled = false;
            NativeMap.UiSettings.RotateGesturesEnabled   = false;
        }
        /// <summary>
        /// This function sets up basic variables on the GoogleMap as
        /// soon as it is ready.
        /// </summary>
        /// <param name="map">Googlemap object we are using.</param>
        protected override void OnMapReady(Android.Gms.Maps.GoogleMap map)
        {
            if (mapDrawn)
            {
                return;
            }

            base.OnMapReady(map);
            map.UiSettings.ZoomControlsEnabled     = false;
            map.UiSettings.MyLocationButtonEnabled = false;
            map.UiSettings.RotateGesturesEnabled   = false;
            map.UiSettings.MapToolbarEnabled       = false;

            KCApi.Properties.Renderer    = this;
            KCApi.Properties.RenderReady = true;

            mapDrawn = true;

            UpdateMarker();
        }
Beispiel #47
0
        async void markPlaces(List <Place> places)
        {
            MapFragment mapFrag = (MapFragment)FragmentManager.FindFragmentById(Resource.Id.map);

            Android.Gms.Maps.GoogleMap map = mapFrag.Map;

            foreach (Place place in places)
            {
                drawMark("pitStop", place.Location);
            }

            LatLng location2 = new LatLng(places[4].Location.latitude, places[4].Location.longitude);

            CameraPosition.Builder builder = CameraPosition.InvokeBuilder();
            builder.Target(location2);
            builder.Zoom(12);
            //builder.Bearing(155);
            //builder.Tilt(65);
            CameraPosition cameraPosition = builder.Build();
            CameraUpdate   cameraUpdate   = CameraUpdateFactory.NewCameraPosition(cameraPosition);

            map.MoveCamera(cameraUpdate);
        }
Beispiel #48
0
        protected virtual void OnMapReady(Android.Gms.Maps.GoogleMap nativeMap, Map map)
        {
            if (nativeMap != null)
            {
                _cameraLogic.Register(map, nativeMap);

                _uiSettingsLogic.Register(map, nativeMap);
                Map.OnSnapshot += OnSnapshot;

                nativeMap.SetOnMapClickListener(this);
                nativeMap.SetOnMapLongClickListener(this);
                nativeMap.SetOnMyLocationButtonClickListener(this);

                UpdateIsShowingUser(_uiSettingsLogic.MyLocationButtonEnabled);
                UpdateHasScrollEnabled(_uiSettingsLogic.ScrollGesturesEnabled);
                UpdateHasZoomEnabled(_uiSettingsLogic.ZoomControlsEnabled, _uiSettingsLogic.ZoomGesturesEnabled);
                UpdateHasRotationEnabled(_uiSettingsLogic.RotateGesturesEnabled);
                UpdateIsTrafficEnabled();
                UpdateIndoorEnabled();
                UpdateMapStyle();
                UpdateMyLocationEnabled();
                _uiSettingsLogic.Initialize();

                SetMapType();
                SetPadding();

                //UpdateMaxZoom();

                //UpdateMinZoom();
            }

            _ready = true;
            if (_ready && _onLayout)
            {
                InitializeLogic();
            }
        }
 void IOnMapReadyCallback.OnMapReady(Android.Gms.Maps.GoogleMap googleMap)
 {
     handler?.Invoke(googleMap);
 }
 protected override void OnMapReady(Android.Gms.Maps.GoogleMap map)
 {
     base.OnMapReady(map);
     nativeMap              = map;
     nativeMap.MarkerClick += NativeMap_MarkerClick;
 }
Beispiel #51
0
 public void OnMapReady(GMaps.GoogleMap googleMap)
 {
     this.googleMap = googleMap;
     InitializeElement();
 }
Beispiel #52
0
 public void OnMapReady(GoogleMap googleMap)
 {
     _map = googleMap;
 }
Beispiel #53
0
        protected override async void OnElementChanged(ElementChangedEventArgs <Map> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement == e.NewElement)
            {
                return;
            }

            //// For XAML Previewer or FormsGoogleMaps.Init not called.
            if (!FormsGoogleMaps.IsInitialized)
            {
                var tv = new TextView(Context)
                {
                    Gravity = GravityFlags.Center,
                    Text    = "Bizland.Core"
                };
                tv.SetBackgroundColor(Color.Teal.ToAndroid());
                tv.SetTextColor(Color.Black.ToAndroid());
                SetNativeControl(tv);
                return;
            }

            // Uninitialize old view
            Android.Gms.Maps.GoogleMap oldNativeMap = null;
            Map oldMap = null;

            if (e.OldElement != null)
            {
                try
                {
                    var oldNativeView = Control as MapView;
                    // ReSharper disable once PossibleNullReferenceException
                    oldNativeMap = await oldNativeView?.GetGoogleMapAsync();

                    oldMap = e.OldElement;
                    Uninitialize(oldNativeMap, oldMap);
                    oldNativeView?.Dispose();
                }
                catch (System.Exception ex)
                {
                    var message = ex.Message;
                    System.Diagnostics.Debug.WriteLine($"Uninitialize old view failed. - {message}");
                }
            }

            if (e.NewElement == null)
            {
                return;
            }

            var mapView = new MapView(Context);

            mapView.OnCreate(s_bundle);
            mapView.OnResume();
            SetNativeControl(mapView);

            var activity = Context as Activity;

            if (activity != null)
            {
                _scaledDensity             = activity.GetScaledDensity();
                _cameraLogic.ScaledDensity = _scaledDensity;
                foreach (var logic in _logics)
                {
                    logic.ScaledDensity = _scaledDensity;
                }
            }

            var newMap = e.NewElement;

            NativeMap = await mapView.GetGoogleMapAsync();

            foreach (var logic in _logics)
            {
                logic.Register(oldNativeMap, oldMap, NativeMap, newMap);
                logic.ScaledDensity = _scaledDensity;
            }
            if (Map.IsUseCluster)
            {
                _clusterLogic.Register(oldNativeMap, oldMap, NativeMap, newMap);
                _clusterLogic.ScaledDensity = _scaledDensity;
            }

            OnMapReady(NativeMap, newMap);
        }