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

            var camera = CameraPosition.FromCamera (-37.81969, 144.966085, 4);
            mapView = MapView.FromCamera (RectangleF.Empty, camera);
            View = mapView;

            mapView.LongPress += HandleLongPress;

            // Add a default marker around Sydney.
            var sydneyMarker = new Marker () {
                Title = "Sydney!",
                Icon = UIImage.FromBundle ("glow-marker"),
                Position = new CLLocationCoordinate2D (-33.8683, 151.2086),
                Map = mapView
            };

            // Create a list of markers, adding the Sydney marker.
            markers = new List<Marker> () { sydneyMarker };

            // Create a button that, when pressed, updates the camera to fit the bounds
            // of the specified markers.
            var fitBoundsButton = new UIBarButtonItem ("Fit Bounds", UIBarButtonItemStyle.Plain, DidTapFitBounds);
            NavigationItem.RightBarButtonItem = fitBoundsButton;
        }
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			var camera = CameraPosition.FromCamera (-37.81969, 144.966085, 4);
			var mapView = MapView.FromCamera (CGRect.Empty, camera);

			var sydneyMarker = new Marker () {
				Title = "Sydney",
				Snippet = "Population: 4,605,992",
				Position = new CLLocationCoordinate2D (-33.8683, 151.2086),
				Map = mapView
			};

			var melbourneMarker = new Marker () {
				Title = "Melbourne",
				Snippet = "Population: 4,169,103",
				Position = new CLLocationCoordinate2D (-37.81969, 144.966085),
				Map = mapView
			};

			// Set the marker in Sydney to be selected
			mapView.SelectedMarker = sydneyMarker;

			View = mapView;
		}
		public override void LoadView ()
		{
			base.LoadView ();

			//Definimos una cámara y le indicamos el punto inicial donde queremos que
			//nuestro mapa aparezca así como el zoom 
			CameraPosition camera = CameraPosition.FromCamera (21.121694,-101.6641149, 12);

			//Le asignamos la cámara a nuestra variable mapView
			mapView = MapView.FromCamera (RectangleF.Empty, camera);
			mapView.MyLocationEnabled = true;

			//Definimos un Marcador para nuestro mapa
			var xamMarker = new Marker () {
				Title = "Marcador",
				Snippet = "Cuerpo del marcador",
				Position = new CLLocationCoordinate2D (21.121694,-101.6641149),
				Map = mapView
			};


			//Personalizamos la imagen de nuestro marcador
			xamMarker.Icon=UIImage.FromBundle ("p_n");

			this.View = mapView;


		}
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			var camera = CameraPosition.FromCamera (-33.868, 151.2086, 12);
			mapView = MapView.FromCamera (CGRect.Empty, camera);
			geocoder = new Geocoder ();

			mapView.CoordinateLongPressed += (sender, e) => {
				// On a long press, reverse geocode this location.
				geocoder.ReverseGeocodeCord (e.Coordinate, (response, error) => {
					if (response != null && response.FirstResult != null) {
						var marker = new Marker () {
							Position = e.Coordinate,
							Title = response.FirstResult.AddressLine1,
							Snippet = response.FirstResult.AddressLine2,
							AppearAnimation = MarkerAnimation.Pop,
							Map = mapView
						};
					} else {
						Console.WriteLine (string.Format ("Could not reverse geocode point ({0},{1}): {2}", 
							e.Coordinate.Latitude, e.Coordinate.Longitude, error));
					}
				});
			};

			View = mapView;
		}
        private void UpdatePins()
        {
            try
            {
                var mapTile = (MapTile)Element;
                var map = Control as MapView;
                map.Clear();
                foreach (var item in mapTile.PinList)
                {
                    var categoryParam = CategoryHelper.CategoryList[item.PrimaryCategory.TypeCode];

                    Marker marker = new Marker();
                    marker.Position = new CoreLocation.CLLocationCoordinate2D(item.Latitude, item.Longitude);
                    marker.Icon = UIImage.FromFile(categoryParam.Icon);
                    marker.Map = map;
                    marker.UserData = NSObject.FromObject(item.Id);
                }

                if (AppMobileService.Locaion.IsAvailable())
                {
                    Marker marker = new Marker();
                    marker.Position = new CoreLocation.CLLocationCoordinate2D(AppMobileService.Locaion.CurrentLocation.Latitude, AppMobileService.Locaion.CurrentLocation.Longitude);
                    marker.Icon = UIImage.FromFile(@"MapPins/ic_pin_navigation.png");
                    marker.Map = map;
                }
            }
            catch
            { }
        }
Beispiel #6
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            this.NavigationController.HidesBottomBarWhenPushed = true;
            this.NavigationController.NavigationBar.Hidden = false;
            this.NavigationController.NavigationBar.TintColor = UIColor.White;
            this.NavigationController.NavigationBar.BarTintColor = UIColor.FromRGB(44/255f,146/255f,208/255f);
            UINavigationBar.Appearance.SetTitleTextAttributes(new UITextAttributes { TextColor = UIColor.White });
            Title = "Map";
            CameraPosition camera = CameraPosition.FromCamera(33.4264393, -111.9868498, 6);

            mapView = MapView.FromCamera (new CGRect(0,64,UIScreen.MainScreen.Bounds.Width,UIScreen.MainScreen.Bounds.Height-64), camera);
            mapView.MyLocationEnabled = true;

            var xamMarker = new Marker () {
                Title = "",
                Snippet = "",
                Position = new CLLocationCoordinate2D (33.4264393, -111.9868498),
                Map = mapView
            };

            mapView.SelectedMarker = xamMarker;
            this.View.AddSubview (mapView);
        }
        void HandleLongPress(object sender, GMSCoordEventArgs e)
        {
            var marker = new Marker () {
                Title = string.Format ("Marker at: {0}, {1}", e.Coordinate.Latitude, e.Coordinate.Longitude),
                Position = e.Coordinate,
                AppearAnimation = MarkerAnimation.Pop,
                Map = mapView
            };

            // Add the new marker to the list of markers.
            markers.Add (marker);
        }
 public void WillRenderMarker(GMUClusterRenderer renderer, Overlay marker)
 {
     Google.Maps.Marker gmsMarker = marker as Marker;
     if (gmsMarker.UserData.GetType() == typeof(GMUStaticCluster))
     {
         GMUStaticCluster cluster = gmsMarker.UserData as GMUStaticCluster;
         // set a custom icon or view here
     }
     else
     {
         POIItem clustItem = gmsMarker.UserData as POIItem;
         // set a custom icon or view here
     }
 }
		void AddDefaultMarkers () 
		{
			var sydneyMarker = new Marker () {
				Title = "Sydney!",
				Icon = UIImage.FromBundle ("glow-marker"),
				Position = new CLLocationCoordinate2D (-33.8683, 151.2086),
				Map = mapView
			};
			
			var melbourneMarker = new Marker () {
				Title = "Melbourne!",
				Icon = UIImage.FromBundle ("arrow"),
				Position = new CLLocationCoordinate2D (-37.81969, 144.966085),
				Map = mapView
			};
		}
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			var camera = CameraPosition.FromCamera (-37.81969, 144.966085, 4);
			mapView = MapView.FromCamera (RectangleF.Empty, camera);

			var sydneyMarker = new Marker () {
				Position = new CLLocationCoordinate2D (-33.8683, 151.2086),
				Map = mapView
			};

			melbourneMarker = new Marker () {
				Position = new CLLocationCoordinate2D (-37.81969, 144.966085),
				Map = mapView
			};

			mapView.InfoFor = (aMapView, aMarker) => {
				if (aMarker == melbourneMarker)
					return new UIImageView (UIImage.FromBundle ("Icon"));
				return null;
			};

			mapView.TappedMarker = (aMapView, aMarker) => {
				// Animate to the marker
				CATransaction.Begin ();
				CATransaction.AnimationDuration = 3;  // 3 second animation
				
				var cam = new CameraPosition (aMarker.Position, 8, 50, 60);
				mapView.Animate (cam);
				CATransaction.Commit ();
				
				// Melbourne marker has a InfoWindow so return NO to allow markerInfoWindow to
				// fire. Also check that the marker isn't already selected so that the
				// InfoWindow doesn't close.
				if (aMarker == melbourneMarker && mapView.SelectedMarker != melbourneMarker) {
					return false;
				}
				
				// The Tap has been handled so return YES
				return true;
			};

			View = mapView;
		}
        public override void LoadView()
        {
            base.LoadView ();

            CameraPosition camera = CameraPosition.FromCamera (37.797865, -122.402526, 6);

            mapView = MapView.FromCamera (RectangleF.Empty, camera);
            mapView.MyLocationEnabled = true;

            var xamMarker = new Marker () {
                Title = "Xamarin HQ",
                Snippet = "Where the magic happens.",
                Position = new CLLocationCoordinate2D (37.797865, -122.402526),
                Map = mapView
            };

            mapView.SelectedMarker = xamMarker;

            View = mapView;
        }
Beispiel #12
0
		void CreateThing (Thing t)
		{
			Marker marker;

			// If the thing don't have a ObjectLocation, than don't draw it
			if (t.ObjectLocation == null)
				return;

			if (!markers.TryGetValue (t.ObjIndex, out marker)) {
				marker = new Marker () {
					Tappable = true,
					Map = mapView
				};
				if (thing is Character) {
					marker.Icon = t.Icon != null && t.Icon == null ? UIImage.LoadFromData (NSData.FromArray (t.Icon.Data)) : Images.IconMapCharacter;
					marker.GroundAnchor = t.Icon != null && t.Icon == null ? new PointF (0.5f, 0.5f) : new PointF (0.3f, 0.92f);
					marker.InfoWindowAnchor = t.Icon != null && t.Icon == null ? new PointF (0.5f, 0.0f) : new PointF (0.3f, 0.0f);
				} else {
					marker.Icon = t.Icon != null && t.Icon == null ? UIImage.LoadFromData (NSData.FromArray (t.Icon.Data)) : Images.IconMapItem;
					marker.GroundAnchor = t.Icon != null && t.Icon == null ? new PointF (0.5f, 0.5f) : new PointF (0.2f, 0.92f);
					marker.InfoWindowAnchor = t.Icon != null && t.Icon == null ? new PointF (0.5f, 0.0f) : new PointF (0.2f, 0.0f);
				}
				markers.Add(t.ObjIndex, marker);
			}
			marker.Title = (t.Name == null ? "" : t.Name);

			var inventory = (WherigoCollection<Thing>)t.Inventory;

			if (inventory.Count > 0) {
				StringBuilder s = new StringBuilder ();

				foreach (Thing thing in inventory) {
					s.Append ((s.Length > 0 ? ", " : "") + (thing.Name == null ? "" : thing.Name));
				}

				marker.Snippet = Catalog.Format(Catalog.GetString("Contains {0}"), s.ToString());
			}

			marker.ZIndex = 100;
			((Marker)marker).Position = new CLLocationCoordinate2D(t.ObjectLocation.Latitude, t.ObjectLocation.Longitude);
		}
            public override void DidTapAtCoordinate(MapView mapView, CLLocationCoordinate2D coordinate)
            {

                //Create/Add Marker 
                var marker = new Marker { Position = coordinate, Map = mapView };
                Locations.Add(coordinate);

                if (Locations.Count > 1)
                {
                    SetDirectionsQuery();
                }
            }
 public void AddMarkerTo(MapView map)
 {
     Marker = new Marker () {
         Position = new CLLocationCoordinate2D(Entity.Latitude, Entity.Longitude),
         Title = Entity.Name,
         Snippet = Entity.EntityType.ToString (),
         Map = map,
         Icon = IconForCurrentIconType
     };
 }
			protected override void HighlightRoutes ()
			{
				_outer._btnRight.Enabled = _highlighedIndex != (_pointDrawingInfos.Count - 1);
				_outer._btnLeft.Enabled  = _highlighedIndex != 0;

				_outer._btnSelStart.SetTitle (_pointDrawingInfos [_highlighedIndex].Point.Name,
					UIControlState.Normal);

				MapView.Clear ();
				_markers.Clear ();
				_routeLines.Clear();

				foreach (var pdi in _pointDrawingInfos)
				{
					// draw markers
					var mPlace = pdi.Point;
					var marker = new Marker () {
						Title = mPlace.Name,
						Position = Utils.GetCLLoc(mPlace.Loc),
						Map = MapView
					};

					if (pdi == _highlighedPoint)
						MapView.SelectedMarker = marker;

					_markers.Add (marker);

					DrawPolyline(pdi.Polyline);
				}
			}
Beispiel #16
0
		void CreateZone(Zone z)
		{
			Overlay polygon;
			Marker marker;

			if (!z.Active || !z.Visible) {
				if (overlays.ContainsKey (z.ObjIndex)) {
					overlays.TryGetValue (z.ObjIndex, out polygon);
					if (polygon != null) 
						polygon.Map = null;
					overlays.Remove (z.ObjIndex);
					markers.TryGetValue (z.ObjIndex, out marker);
					if (marker != null)
						marker.Map = null;
					markers.Remove (z.ObjIndex);
				}
				return;
			}

			if (!overlays.TryGetValue(z.ObjIndex, out polygon)) {
				polygon = new Polygon () {
					FillColor = Colors.ZoneFill,
					StrokeColor = Colors.ZoneStroke,
					StrokeWidth = 2,
					Tappable = true,
					Map = mapView
				};
				overlays.Add (z.ObjIndex, polygon);
			}

			if (!markers.TryGetValue(z.ObjIndex, out marker)) {
				marker = new Marker () {
					Tappable = true,
					Icon = (z.Icon != null ? UIImage.LoadFromData (NSData.FromArray (z.Icon.Data)) : Images.IconMapZone),
					GroundAnchor = z.Icon != null ? new PointF(0.5f, 0.5f) : new PointF(0.075f, 0.95f),
					InfoWindowAnchor = z.Icon != null ? new PointF(0.5f, 0.5f) : new PointF(0.075f, 0.0f),
					Map = mapView
				};
				markers.Add (z.ObjIndex, marker);
			}

			polygon.Title = z.Name;
			marker.Title = z.Name;

			var inventory = (WherigoCollection<Thing>)z.Inventory;

			if (inventory.Count > 0) {
				StringBuilder s = new StringBuilder ();

				foreach (Thing thing in inventory) {
					s.Append ((s.Length > 0 ? ", " : "") + (thing.Name == null ? "" : thing.Name));
				}

				marker.Snippet = Catalog.Format(Catalog.GetString("Contains {0}"), s.ToString());
			}
				
			MutablePath path = new MutablePath ();;
			WherigoCollection<ZonePoint> points = z.Points;

			double lat = 0;
			double lon = 0;

			foreach (ZonePoint zp in points) {
				lat += zp.Latitude;
				lon += zp.Longitude;
				path.AddLatLon (zp.Latitude, zp.Longitude);
			}

			((Polygon)polygon).Path = path;
			polygon.ZIndex = 50;

			marker.Position = new CLLocationCoordinate2D ((float)lat / (float)points.Count, (float)lon / (float)points.Count);
			marker.ZIndex = 100;
		}
        async private void TappedMarker(Marker marker)
        {
            if ((marker == null) || (marker.UserData == null))
                return;

            string pinId = marker.UserData.ToString();

            var map = Control as MapView;
            var mapTile = (MapTile)Element;
            
            var mapPinData = mapTile.PinList.First(x => x.Id == pinId);
            if (mapPinData != null)
            {
                var categoryParam = CategoryHelper.CategoryList[mapPinData.PrimaryCategory.TypeCode];
                marker.Icon = UIImage.FromFile(categoryParam.Icon).Scale(new CGSize(marker.Icon.Size.Width * 1.2, marker.Icon.Size.Height * 1.2)); ;
                await Task.Delay(200);
                marker.Icon = UIImage.FromFile(categoryParam.Icon);
            }



            /*CABasicAnimation rotationAnimation = CABasicAnimation.FromKeyPath("opacity");
            rotationAnimation.From = NSNumber.FromDouble(1);
            rotationAnimation.To = NSNumber.FromDouble(0.4);
            rotationAnimation.RepeatCount = 1;
            rotationAnimation.Duration = 0.4;
            marker.Layer.AddAnimation(rotationAnimation, "rotationAnimation");*/
            

            var centerLocation = new CLLocationCoordinate2D(Math.Round(map.Camera.Target.Latitude, 4), Math.Round(map.Camera.Target.Longitude, 4));
            var pinLocation = new CLLocationCoordinate2D(Math.Round(marker.Position.Latitude, 4), Math.Round(marker.Position.Longitude, 4));

            if ((centerLocation.Latitude == pinLocation.Latitude) & (centerLocation.Longitude == pinLocation.Longitude))
            {
                mapTile.ShowPinDetailInfo(pinId);
                pinId = "";
            }
            else
            {
                float zoom = (map.Camera.Zoom > 13) ? map.Camera.Zoom : 13;
                CameraPosition camera = CameraPosition.FromCamera(marker.Position.Latitude, marker.Position.Longitude, zoom);
                map.Animate(camera);

                map.CameraPositionChanged += async (s, e) =>
                {
                    if (!String.IsNullOrWhiteSpace(pinId))
                    {
                        await Task.Delay(500);
                        mapTile.ShowPinDetailInfo(pinId);
                    }
                    pinId = "";
                };
            };
        }