当前位置: 首页>>代码示例>>C#>>正文


C# GoogleMap.AddMarker方法代码示例

本文整理汇总了C#中Android.Gms.Maps.GoogleMap.AddMarker方法的典型用法代码示例。如果您正苦于以下问题:C# GoogleMap.AddMarker方法的具体用法?C# GoogleMap.AddMarker怎么用?C# GoogleMap.AddMarker使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Android.Gms.Maps.GoogleMap的用法示例。


在下文中一共展示了GoogleMap.AddMarker方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnResume

		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;
		}
开发者ID:flolovebit,项目名称:xamarin-evolve-2014,代码行数:59,代码来源:MainActivity.cs

示例2: OnMapReady

        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;
        }
开发者ID:Reinierr,项目名称:Project4,代码行数:50,代码来源:gmaps.cs

示例3: FindMap

		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));
					}
				}
			}
		}
开发者ID:foxanna,项目名称:SimpleLocationAlarm,代码行数:34,代码来源:HomeActivityMapWork.cs

示例4: MapRoute

        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));
        }
开发者ID:Lichwa,项目名称:JakDojadeXamarin,代码行数:35,代码来源:MapRoute.cs

示例5: CargamosMarcadores

		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));

				}

			}
		}
开发者ID:DiLRandI,项目名称:Xamarin.android,代码行数:27,代码来源:MainActivity.cs

示例6: OnMapReady

 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));
 }
开发者ID:FirstClickStart,项目名称:yesterdaysMuffins,代码行数:12,代码来源:SplitStreetViewPanoramaAndMapDemoActivity.cs

示例7: OnMapReady

		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);
			};
		}
开发者ID:RimvydasJ,项目名称:Application,代码行数:14,代码来源:GoogleMaps.cs

示例8: OnElementChanged

        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;
        }
开发者ID:jiletx,项目名称:Bluemart,代码行数:50,代码来源:ExtendedMapRenderer.cs

示例9: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            SetContentView (Resource.Layout.dashboard_listview_detail);
            progress = new ProgressDialog (this);
            lat = 37.09035962;
            lan = -95.71368456;
            flag = FindViewById<ImageView> (Resource.Id.ivNew1);
            flag.Click += Flag_Click;
            ivListEmpty = FindViewById<LinearLayout> (Resource.Id.ivEmptylist);
            lvlist = FindViewById<ListView> (Resource.Id.lvListDetail);
            llMap = FindViewById<RelativeLayout> (Resource.Id.llmap);
            tvnumber = FindViewById<TextView> (Resource.Id.tvNumber);
            tvdesc = FindViewById<TextView> (Resource.Id.tvdesc);
            tvtime = FindViewById<TextView> (Resource.Id.tvTime);
            tvreply = FindViewById<TextView> (Resource.Id.tvReply);
            ListSipp = new List<SippReplyModel> ();

            Typeface tf = Typeface.CreateFromAsset (Application.Context.Assets, "fonts/OpenSans-Light.ttf");
            Typeface tf1 = Typeface.CreateFromAsset (Application.Context.Assets, "fonts/OpenSans-Semibold.ttf");
            Typeface tf2 = Typeface.CreateFromAsset (Application.Context.Assets, "fonts/OpenSans-Bold.ttf");

            adapter = new CustomListViewDetail (this, ListSipp);
            lvlist.Adapter = adapter;
            if (adapter.IsEmpty) {
                ivListEmpty.Visibility = ViewStates.Visible;
            } else {
                ivListEmpty.Visibility = ViewStates.Gone;
            }

            mapFrag = (MapFragment)FragmentManager.FindFragmentById (Resource.Id.map);
            map = mapFrag.Map;
            map.UiSettings.CompassEnabled = true;
            map.UiSettings.ZoomControlsEnabled = false;
            map.MyLocationEnabled = false;

            LatLng lastLatLng = new LatLng (lat, lan);
            map.MoveCamera (CameraUpdateFactory.NewLatLngZoom (lastLatLng, 15));
            MarkerOptions marker = new MarkerOptions ();
            marker.SetPosition (new LatLng (lat, lan));
            map.AddMarker (marker);
            llMap.Background.SetAlpha (200);
            llMap.Click += LlMap_Click;
            tvnumber.SetTypeface (tf, TypefaceStyle.Normal);
            tvnumber.SetTypeface (tf2, TypefaceStyle.Normal);
            tvtime.SetTypeface (tf1, TypefaceStyle.Normal);
            tvreply.SetTypeface (tf1, TypefaceStyle.Normal);
        }
开发者ID:ppkdo,项目名称:sipper,代码行数:49,代码来源:DashBoardListViewDetail.cs

示例10: OnResume

		public override void OnResume ()
		{
			base.OnResume ();

			_map = _myMapFrag.Map;//see GetMapAsync for a non-blocking solution

			_map.MapType = GoogleMap.MapTypeSatellite;

			MarkerOptions markerOp = new MarkerOptions()
				.SetPosition(LatLong_Van)
				.SetTitle("Vancouver")
				.SetSnippet("BC, Canada")
				.InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueGreen));
			_map.AddMarker(markerOp);
		}
开发者ID:berlamont,项目名称:XamarinAndroidFlyoutMaps,代码行数:15,代码来源:MyMapFragment.cs

示例11: OnMapReady

        public void OnMapReady(GoogleMap googleMap)
        {
            map = googleMap;
            map.MyLocationEnabled = true;
            map.MapType = GoogleMap.MapTypeNormal;
            map.UiSettings.ZoomControlsEnabled = true;

            //map.UiSettings.CompassEnabled = true;
            map.UiSettings.SetAllGesturesEnabled(true);
            //map.UiSettings.RotateGesturesEnabled = true;
            map.AddMarker(new MarkerOptions().SetPosition(Location_NewYork));
            map.SetOnMarkerClickListener (this);

            /*LocationManager locManager = GetSystemService (Context.LocationService) as LocationManager;
            if (locManager.IsProviderEnabled (LocationManager.GpsProvider)) {
                locManager.RequestLocationUpdates (1000, 10, criteria, this, null);
            }

            else
            {
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                builder.SetTitle("GPS Disabled");
                builder.SetMessage("Enable GPS to use the app");
                builder.SetCancelable(false);
                builder.SetPositiveButton("OK", delegate { StartActivityForResult (new Intent(Android.Provider.Settings.ActionLocationSourceSettings), 0);
                });
                builder.Show();
            }*/
            FindViewById<Button> (Resource.Id.sharebutton).Click += delegate {
                {
                    var geoUri = Android.Net.Uri.Parse ("geo:"+ _currentLocation.Latitude+","+_currentLocation.Longitude);
                    var mapIntent = new Intent (Intent.ActionView, geoUri);
                    //mapIntent.SetType(
                    //StartActivity (mapIntent);

                    var smsUri = Android.Net.Uri.Parse("smsto:1234567890");
                    var smsIntent = new Intent (Intent.ActionSendto, smsUri);
                    StringBuilder smsstring = new StringBuilder();
                    smsstring.Append("Click the link to track ");
                    smsstring.Append("http://maps.google.com?q=");
                    smsstring.Append(_currentLocation.Latitude);
                    smsstring.Append(",");
                    smsstring.Append(_currentLocation.Longitude);
                    smsIntent.PutExtra ("sms_body",smsstring.ToString() );
                    StartActivity (smsIntent);
                }
            };
        }
开发者ID:Dev-Idres,项目名称:MyFriends,代码行数:48,代码来源:MainActivity.cs

示例12: OnCreate

 protected override void OnCreate(Bundle bundle)
 {
     base.OnCreate (bundle);
     SetContentView (Resource.Layout.map_activity);
     lat = Intent.GetDoubleExtra ("lat", 0);
     lan = Intent.GetDoubleExtra ("lan", 0);
     mapFrag = (MapFragment)FragmentManager.FindFragmentById (Resource.Id.map);
     map = mapFrag.Map;
     map.UiSettings.CompassEnabled = true;
     map.UiSettings.ZoomControlsEnabled = true;
     LatLng lastLatLng = new LatLng (lat, lan);
     map.MoveCamera (CameraUpdateFactory.NewLatLngZoom (lastLatLng, 15));
     MarkerOptions marker = new MarkerOptions ();
     marker.SetPosition (new LatLng (lat, lan));
     map.AddMarker (marker);
 }
开发者ID:ppkdo,项目名称:sipper,代码行数:16,代码来源:MapActivity.cs

示例13: PlaceMarkersOnTheMap

        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);
            }
        }
开发者ID:znajdzWC,项目名称:znajdz-wc-android,代码行数:19,代码来源:GoogleMapHelpers.cs

示例14: SetupMapIfNeeded

		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);
				}
			}
		}
开发者ID:KiranKumarAlugonda,项目名称:NPlus1DaysOfMvvmCross,代码行数:23,代码来源:SampleMapActivity.cs

示例15: OnMapReady

		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);
		}
开发者ID:kosomgua,项目名称:MapCross,代码行数:24,代码来源:MapView.cs


注:本文中的Android.Gms.Maps.GoogleMap.AddMarker方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。