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


C# MarkerOptions.SetPosition方法代码示例

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


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

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

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

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

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

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

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

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

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

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

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

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

示例15: googleMap_MapClick

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


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