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


C# Model.MarkerOptions类代码示例

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


MarkerOptions类属于Android.Gms.Maps.Model命名空间,在下文中一共展示了MarkerOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: setAdress

        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)
            };
        }
开发者ID:HeikkiDev,项目名称:Mapas_XamarinForms,代码行数:21,代码来源:MyMapRenderer.cs

示例2: OnElementPropertyChanged

        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;

            }
        }
开发者ID:vmoll,项目名称:ShouldIWashMyCar,代码行数:33,代码来源:MapViewRenderer.cs

示例3: OnCreate

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

        }
开发者ID:KiranKumarAlugonda,项目名称:NPlus1DaysOfMvvmCross,代码行数:31,代码来源:FirstView.cs

示例4: OnCreate

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

        }
开发者ID:KiranKumarAlugonda,项目名称:NPlus1DaysOfMvvmCross,代码行数:30,代码来源:SecondView.cs

示例5: 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

示例6: updateEpins

        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);
            }
        }
开发者ID:whosol,项目名称:mapextend-plugin,代码行数:32,代码来源:MapExtendRenderer.cs

示例7: MapRenderer2Android

        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);
            });
        }
开发者ID:RhysPartlett,项目名称:oakville-heritage-properties,代码行数:32,代码来源:MapRenderer2Android.cs

示例8: adddatatomap

        // 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;
        }
开发者ID:TigerIke,项目名称:WIC-PROJECT,代码行数:30,代码来源:MapActivity.cs

示例9: UpdatePins

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

示例10: 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

示例11: addEvent

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

示例12: EntityMarker

 public EntityMarker(BankEntity entity, IconType iconType)
 {
     this.Entity = entity;
     this.MarkerOptions = new MarkerOptions ();
     this.MarkerOptions.SetTitle (entity.Description());
     this.MarkerOptions.SetPosition (new LatLng(entity.Latitude, entity.Longitude));
     this.Type = MarkerType.Regular;
     IconType = iconType;
 }
开发者ID:priyaaank,项目名称:XamarinMapsPoc,代码行数:9,代码来源:EntityMarker.cs

示例13: InitMarkers

 public void InitMarkers()
 {
     foreach (var element in ListMarkers) {
         MarkerOptions markerOptions = new MarkerOptions ();
         markerOptions.SetPosition (new LatLng (element.Coordinate.Latitude, element.Coordinate.Longitude));
         markerOptions.SetIcon(BitmapDescriptorFactory.DefaultMarker ());
         var marker = this.map.AddMarker (markerOptions);
         this.listMarkers.Add (marker);
     }
 }
开发者ID:rubixware,项目名称:blist-mobile,代码行数:10,代码来源:MapActivity.cs

示例14: CreateMarker

        private void CreateMarker()
        {
            var latLng = new LatLng(55.816887, 12.532878);

            var markerOptions = new MarkerOptions()
                .SetPosition(latLng)
                .Draggable(true);
            _meMarker = _map.AddMarker(markerOptions);
            _map.AnimateCamera(CameraUpdateFactory.NewLatLngZoom(latLng, 13));
        }
开发者ID:Cheesebaron,项目名称:AppCompatAndMaps,代码行数:10,代码来源:LocationFragment.cs

示例15: FindCar

        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;
        }
开发者ID:MatejVukosav,项目名称:GdjeMiJeAuto,代码行数:53,代码来源:FinderAlgorithm.cs


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