예제 #1
0
 public async Task OriginAddress()
 {
     try
     {
         // Get Current Lattitude And Latitude
         MyMap.CustomPins = new List <CustomPin>();
         var locator = CrossGeolocator.Current;
         locator.DesiredAccuracy = 50;
         // var position = await locator.GetLastKnownLocationAsync();
         // Xamarin.Forms.Maps.Position position = new Xamarin.Forms.Maps.Position(location.Latitude, location.Longitude);
         var position1 = new Xamarin.Forms.Maps.Position(double.Parse(Helpers.Constant.originLatitude), double.Parse(Helpers.Constant.originLongitude)); // Latitude, Longitude
         MyMap.MoveToRegion(new MapSpan(position1, 1, 1));
         var pin = new CustomPin
         {
             Pin = new Pin
             {
                 Type     = PinType.Place,
                 Position = position1,
                 Label    = "",
                 Id       = "Mastercard",
                 Address  = "",
             }
         };
         pin.Id = "Mastercard";
         MyMap.CustomPins.Add(pin);
         MyMap.Pins.Add(pin.Pin);
     }
     catch (Exception ex)
     {
         ex.ToString();
     }
 }
예제 #2
0
        // Methods (override)
        #region CreateMarker(Pin)

        /// <summary>
        /// 마커의 위치와 라벨을 설정합니다.
        /// </summary>
        /// <param name="pin"></param>
        /// <returns></returns>
        protected override MarkerOptions CreateMarker(Pin pin)
        {
            CustomPin customPin = pin as CustomPin;

            if (customPin == null)
            {
                return(null);
            }

            var marker = new MarkerOptions();

            try
            {
                marker.SetPosition(new LatLng(pin.Position.Latitude, pin.Position.Longitude));
                marker.SetTitle(customPin.Name);
                marker.SetSnippet(pin.Address);
                marker.SetIcon(GenerateMyCustomDrawnOverlay(125, 60, customPin.Label));
            }
            catch
            {
                // 에러무시
            }

            return(marker);
        }
예제 #3
0
        private void OnMarkerClick(object sender, GoogleMap.MarkerClickEventArgs e)
        {
            var selectedMarker = e.Marker;

            if (selectedMarker == null || !_isUserInteractionEnabled)
            {
                // If user interaction is disabled, don't show info window
                e.Handled = true;
                return;
            }

            KeyValuePair <string, Marker> keyPair = GetPushpinMappedMarker(e.Marker);

            // Check if this is a incident marker
            if (keyPair.Equals(default(KeyValuePair <string, Marker>)))
            {
                return;
            }

            CustomPin pin = FormsMap.Pushpins?.Where(i => i.Id == keyPair.Key)
                            .FirstOrDefault();

            if (pin != null)
            {
                OnPushpinSelected(pin);
            }

            _infoWindowAdapter.Duration = pin.Duration;

            // Mark as unhandled (to let info window appear)
            e.Handled = false;
        }
예제 #4
0
 public async void searchLocation()
 {
     if (HomePage.Lat != 0 && HomePage.Lng != 0)
     {
         var start_pin = new CustomPin
         {
             Pin = new Pin
             {
                 Type     = PinType.Place,
                 Position = new Position(Convert.ToDouble(HomePage.Lat), Convert.ToDouble(HomePage.Lng)),
                 Label    = "",
                 Address  = ""
             },
             Id       = "Xamarin",
             startPin = true
         };
         customMap.CustomPins = new List <CustomPin> {
             start_pin
         };
         if (Device.OS == TargetPlatform.iOS)
         {
             customMap.Pins.Add(start_pin.Pin);
         }
         customMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(Convert.ToDouble(HomePage.Lat), Convert.ToDouble(HomePage.Lng)), Xamarin.Forms.Maps.Distance.FromKilometers(10)));
     }
 }
        public override void ShowPushpinInformationPanel(CustomPin pin)
        {
            // search for the annotation in the map
            var annotation = _nativeMap?.Annotations?.OfType <CustomPinAnnotation>().Where(i => i.CustomPin.Id == pin.Id).FirstOrDefault();

            _nativeMap.SelectAnnotation(annotation, false);
        }
예제 #6
0
 public CustomPinControl(CustomPin pin)
 {
     this.InitializeComponent();
     Name.Text        = pin.Name;
     Description.Text = pin.Description;
     Rating.Text      = pin.Rating.ToString();
 }
예제 #7
0
        protected MarkerOptions CreateCustomMarker(CustomPin pin)
        {
            MarkerOptions marker = new MarkerOptions();

            marker.SetPosition(new LatLng(pin.Position.Latitude, pin.Position.Longitude));
            marker.SetTitle(pin.Label);
            marker.SetSnippet(pin.Address);

            //   if (pin.Id.ToString() == "hasClicked")
            CustomPin customP = null;

            foreach (var p in map.Pins)
            {
                if (p.Position == pin.Position)
                {
                    customP = (CustomPin)p;
                    break;
                }
            }
            if (customP.hasClicked)
            {
                marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.pinBlue));
            }
            else if (customP.isYourLocation)
            {
                marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.pinAq));
            }
            else
            {
                marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.pin));
            }
            return(marker);
        }
예제 #8
0
        public Tags(double lat, double longitud)
        {
            InitializeComponent();

            MyMap.CustomPins = new List <CustomPin>();

            Device.BeginInvokeOnMainThread(async() => {
                EntryService entryService = new EntryService();

                List <GeoTaggerEntry> entries = await entryService.GetLastEntries();

                foreach (GeoTaggerEntry entry in entries)
                {
                    var thisPosition = new Position(double.Parse(entry.Lat), double.Parse(entry.Long)); // Latitude, Longitude
                    var pin          = new CustomPin
                    {
                        Type     = PinType.Generic,
                        Position = thisPosition,
                        Label    = entry.Text,
                        Url      = entry.Link
                    };
                    MyMap.CustomPins.Add(pin);
                    MyMap.Pins.Add(pin);
                }
            });

            var mapPosition = new Position(-34, -58);

            MyMap.MoveToRegion(MapSpan.FromCenterAndRadius(mapPosition,
                                                           Distance.FromMiles(1)));
        }
예제 #9
0
        public MapPage()
        {
            InitializeComponent();



            CustomPin pin = new CustomPin
            {
                Pin = new Pin {
                    Type = PinType.Place, Position = new Position(10.333928, 123.934259), Label = "My Current Location", Address = "Benedicto College"
                },
                ID  = "Xamarin",
                Url = "http://google.com"
            };

            customMap.CustomPins = new List <CustomPin> {
                pin
            };

            customMap.Circle = new CustomCircle
            {
                Position = new Position(10.333928, 123.934259),
                Radius   = 300
            };

            customMap.Pins.Add(pin.Pin);

            customMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(10.333928, 123.934259), Distance.FromMiles(0.3)));
            isMapLoaded = true;
        }
예제 #10
0
        protected override async void OnAppearing()
        {
            base.OnAppearing();
            if (!isload)
            {
                CustomMap customMap = new CustomMap()
                {
                    MapType           = MapType.Street,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    VerticalOptions   = LayoutOptions.FillAndExpand,
                };

                var pin = new CustomPin
                {
                    Type     = PinType.Place,
                    Position = new Position(ldvm.CurrentAddress.Latitude, ldvm.CurrentAddress.Longitude),
                    Label    = ldvm.CurrentAddress.CountryName,
                    Address  = ldvm.CurrentAddress.SubLocality + ", " + ldvm.CurrentAddress.Locality + ", " + ldvm.CurrentAddress.PostalCode + "-" + ldvm.CurrentAddress.CountryCode,
                    Id       = "current",
                };

                customMap.CustomPins = new List <CustomPin> {
                    pin
                };
                customMap.Pins.Add(pin);
                customMap.MoveToRegion(MapSpan.FromCenterAndRadius(pin.Position, Distance.FromMiles(1.0)));
                mapgrd.Children.Add(customMap);

                await ldvm.GetLocationDetails();

                isload = true;
            }
        }
예제 #11
0
        /// <summary>
        ///  Makes CustomPins and Polylines for each location
        /// </summary>
        /// <param name="shipLocation"></param>
        private void RegisterLive(ShipLocation shipLocation)
        {
            ColorTypeConverter colorTypeConverter = new ColorTypeConverter();

            Location lastLocation  = shipLocation.LocationsRegistrations.ElementAt(0);
            Location firstLocation = shipLocation.LocationsRegistrations.ElementAt(shipLocation.LocationsRegistrations.Count - 1);

            if (shipLocation.LocationsRegistrations.Count != 0)
            {
                Polyline polyline = new Polyline
                {
                    StrokeWidth = 8,
                    StrokeColor = (Color)colorTypeConverter.ConvertFromInvariantString(shipLocation.Color)
                };
                for (int i = 0; i < shipLocation.LocationsRegistrations.Count; i++)
                {
                    Location currentLocationRegistration = shipLocation.LocationsRegistrations[i];
                    polyline.Geopath.Add(new Position(currentLocationRegistration.Latitude, currentLocationRegistration.Longtitude));
                }
                sharedData.Direction = (float)CalculateDirection(firstLocation, lastLocation);

                CustomPin pin = new CustomPin
                {
                    Type     = PinType.Place,
                    Position = new Position(polyline.Geopath.ElementAt(0).Latitude, polyline.Geopath.ElementAt(0).Longitude),
                    Label    = String.Empty,
                    Address  = "" + shipLocation.ShipId,
                    Name     = "Ship",
                    ShipId   = "" + shipLocation.ShipId,
                    TeamName = shipLocation.TeamName
                };
                mapView.LoadPoints(polyline, pin, shipLocation.ShipId);
            }
        }
예제 #12
0
        public MapPage()
        {
            InitializeComponent();

            var customMap = new CustomMap
            {
                MapType       = MapType.Street,
                WidthRequest  = App.ScreenWidth,
                HeightRequest = App.ScreenHeight
            };

            var pin = new CustomPin
            {
                Type     = PinType.Place,
                Position = new Position(14.022281, 99.533101),
                Label    = "สาขา เมืองกาญ",
                Address  = "ทดสอบ",
                Id       = "Xamarin",
                Url      = "http://xamarin.com/about/"
            };

            customMap.CustomPins = new List <CustomPin> {
                pin
            };
            customMap.Pins.Add(pin);
            customMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(14.022281, 99.533101), Distance.FromKilometers(1.0)));

            Content = customMap;
        }
예제 #13
0
        private async void GetLocations(List <Residence> residences)
        {
            var geoCoder = new Geocoder( );

            foreach (var residence in residences)
            {
                var position = (await geoCoder.GetPositionsForAddressAsync(residence.Address)).ToList( )[0];

                var pin = new CustomPin {
                    Pin = new Pin {
                        Type     = PinType.Place,
                        Position = position,
                        Label    = residence.Address
                    },
                    Residence = residence
                };
                //pin.Clicked += delegate {
                //	Navigation.PushAsync ( new SelectedResidencePage ( residence ), true );
                //};
                map.CustomPins.Add(pin);
                map.Pins.Add(pin.Pin);

                Debug.WriteLine("Latitude: {0} Longitude: {1}", position.Latitude, position.Longitude);
            }

            var locator = CrossGeolocator.Current;

            locator.DesiredAccuracy = 50;

            var devicePosition = await locator.GetPositionAsync(2000);

            map.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(devicePosition.Latitude, devicePosition.Longitude), Distance.FromKilometers(2.0)));
        }
예제 #14
0
        private async Task CreateMap()
        {
            UserFilters = await GetLocation();
            await GetDeals();

            //Map.Pins = Pins;
            //foreach (var item in Pins)
            //{
            //    Map.Pins.Add(item);
            //}

            var pin = new CustomPin
            {
                Type     = PinType.Generic,
                Position = new Position(UserFilters.Location.Latitude, UserFilters.Location.Longitude),
                Label    = "Your Position",
                Address  = ""
            };

            // CustomPins.Add(pin);
            Map.Pins.Add(pin);



            Map.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(UserFilters.Location.Latitude, UserFilters.Location.Longitude),
                                                         Distance.FromMiles(5)));
        }
예제 #15
0
        private void AddFromPushPin(MapView mapView, CustomPin from)
        {
            // Reset previous From pushpin
            var fromTempMarker = _tempMarkers
                                 .FirstOrDefault(p => p.MarkerOptions.Icon == _fromPinIcon);

            if (fromTempMarker != null)
            {
                fromTempMarker.MarkerOptions.SetIcon(_pinIcon);
            }

            // Set new From pushpin
            if (from != null)
            {
                from.Type = CustomPin.AnnotationType.From;

                var newFromTempMarker = _tempMarkers
                                        .FirstOrDefault(p => p.Id == from.Id);

                if (newFromTempMarker != null)
                {
                    newFromTempMarker.MarkerOptions.SetIcon(_fromPinIcon);
                }
            }

            ClearPushPins(mapView);
            AddPushPins(mapView, _tempMarkers);
        }
예제 #16
0
        private void AddToPushPin(MapView mapView, CustomPin to)
        {
            // Reset previous To pushpin
            var toTempMarker = _tempMarkers
                               .FirstOrDefault(p => p.MarkerOptions.Icon == _toPinIcon);

            if (toTempMarker != null)
            {
                toTempMarker.MarkerOptions.SetIcon(_pinIcon);
            }

            // Set new To pushpin
            if (to != null)
            {
                to.Type = CustomPin.AnnotationType.To;

                var newToTempMarker = _tempMarkers
                                      .FirstOrDefault(p => p.Id == to.Id);

                if (newToTempMarker != null)
                {
                    newToTempMarker.MarkerOptions.SetIcon(_toPinIcon);
                }
            }

            ClearPushPins(mapView);
            AddPushPins(mapView, _tempMarkers);
        }
예제 #17
0
        public RouteStopPage()
        {
            BindingContext = new RouteStopViewModel();
            InitializeComponent();



            var pin = new CustomPin
            {
                Type     = PinType.Place,
                Position = new Position(41.411835, -75.665245),
                Label    = "The Office",
                Address  = "Scranton PA",
                Id       = "Xamarin",
                Url      = "http://xamarin.com/about/"
            };

            // customMap.CustomPins = new List<CustomPin> { pin };
            customMap.PinCollection = new ObservableRangeCollection <CustomPin> {
                pin
            };

            customMap.Pins.Add(pin);
            //customMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(37.79752, -122.40183), Distance.FromMiles(1.0)));
        }
예제 #18
0
 private void CreatePin()
 {
     if (_isSetCoordinate && !string.IsNullOrEmpty(Name) && !string.IsNullOrEmpty(Description))
     {
         List <CustomPin> pins;
         pins = new List <CustomPin>();
         if (App.Current.Properties.ContainsKey("Pins"))
         {
             var oldPins = (List <CustomPin>)App.Current.Properties["Pins"];
             foreach (var customPin in oldPins)
             {
                 pins.Add(customPin);
             }
         }
         else
         {
             App.Current.Properties.Add("Pins", pins);
         }
         var pin = new CustomPin()
         {
             Name        = Name,
             Description = Description,
             Rating      = Rating,
             Position    = new Position(Latitude, Longitude)
         };
         pins.Add(pin);
         App.Current.Properties["Pins"] = pins;
         Navigation.PopAsync();
         MessagingCenter.Send(this, "PinAdded");
     }
     else
     {
         IsWarningVisible = true;
     }
 }
예제 #19
0
        private MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation)
        {
            MKAnnotationView annotationView = null;

            if (annotation is MKUserLocation)
            {
                return(null);
            }

            MKPointAnnotation anno      = annotation as MKPointAnnotation;
            CustomPin         customPin = GetCustomPin(anno);

            if (customPin == null)
            {
                throw new Exception("Custom pin not found");
            }

            annotationView = mapView.DequeueReusableAnnotation(customPin.Id);
            if (annotationView == null)
            {
                annotationView                              = new CustomMKAnnotationView(annotation, customPin.Id);
                annotationView.Image                        = UIImage.FromFile("newpin.png");
                annotationView.CalloutOffset                = new CGPoint(0, 0);
                annotationView.LeftCalloutAccessoryView     = new UIImageView(UIImage.FromFile("businfo2.png"));
                annotationView.RightCalloutAccessoryView    = UIButton.FromType(UIButtonType.DetailDisclosure);
                ((CustomMKAnnotationView)annotationView).Id = customPin.Id;
            }
            annotationView.CanShowCallout = true;

            return(annotationView);
        }
예제 #20
0
        private async void AddPinOnLoad()
        {
            lat = viewModel.Item.lat;
            lng = viewModel.Item.lon;

            ParkingLotList lots = await parkingLotService.GetParkingLots();

            OldParkingLot lot;

            if (viewModel.Item.Id != "1")
            {
                lot = lots.parkingLotList[1];
            }
            else
            {
                lot = lots.parkingLotList[0];
            }

            CustomPin lotPin = new CustomPin
            {
                Type     = PinType.Place,
                Position = new Position(lot.lat, lot.lon),
                Label    = viewModel.Item.lotName + " Open Spots: " + lot.OpenSpots,
                id       = "lot" + viewModel.Item.Id,
                url      = ""
            };

            customMap.Pins.Add(lotPin);


            customMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(lat, lng), Distance.FromMiles(0.1)));
            Content = customMap;
        }
예제 #21
0
        private void AddPinsFromList()
        {
            foreach (StationViewModel station in viewModel.StationList)
            {
                var position = new Position(station.latitude,
                                            station.longitude);


                var customPin = new CustomPin()
                {
                    Pin = new Pin
                    {
                        Type     = PinType.Place,
                        Label    = station.Name,
                        Position = position
                    },
                    ImageSource = GetImageString(station.Lines)
                };

                /*
                 * var pin = new Pin
                 * {
                 *  Type = PinType.Place,
                 *  Label = station.Name,
                 *  Position = position
                 * };
                 * Map.Pins.Add(pin);
                 */

                Map.CustomPins.Add(customPin);
                Map.Pins.Add(customPin.Pin);
            }
        }
예제 #22
0
        private void LoadMap()
        {
            double firstLongitude = ProductDetailsViewModel.Prices.FirstOrDefault().Market.Longitude;
            double firstLatitude  = ProductDetailsViewModel.Prices.FirstOrDefault().Market.Latitude;

            MapProduct.PinCustomizados = new List <CustomPin>();

            foreach (var item in ProductDetailsViewModel.Prices)
            {
                var pin = new CustomPin
                {
                    Type     = PinType.Place,
                    Position = new Position(item.Market.Latitude, item.Market.Longitude),
                    Label    = string.Format(CultureInfo.GetCultureInfo("pt-BR"), "R$ {0:0.00}", item.Value),
                    Address  = $"{item.Market.Name} - {item.Market.Address}, {item.Market.AddressNumber} - {item.Market.District} - {item.Market.City} - {item.Market.State} - {item.Market.Zipcode}",
                    Id       = item.Market,
                    //Localizacao = $"{item.Market.Website}"
                };
                MapProduct.PinCustomizados.Add(pin);
                MapProduct.Pins.Add(pin);
            }
            MapProduct.MoveToRegion(
                MapSpan.FromCenterAndRadius(
                    new Position(firstLatitude, firstLongitude), Distance.FromMiles(1.0)));
        }
        /*TE: Created a separate function to to create a pin on the map.*/
        private void CreateLocationPin(double Latitude, double Longitude)
        {
            Console.WriteLine("Creating pin for location selection");

            /*TE: Clear both list otherwise multiple pins will be created.*/
            formsMap.CustomPins.Clear();
            formsMap.Pins.Clear();
            formsMap.selectedLatitude  = Latitude;
            formsMap.selectedLongitude = Longitude;

            var nativeMap = Control as MKMapView;

            CustomPin newEventPin = new CustomPin
            {
                Id              = "Xamarin",
                Type            = PinType.Place,
                Position        = new Xamarin.Forms.Maps.Position(Latitude, Longitude),
                Label           = "Location Pin",
                Address         = "1<$EVENT_ID$Use This Location for Event",
                Url             = "EventDetailsPage",
                BuildingName    = "",
                EventTime       = "",
                foodFinderEvent = null
            };

            /*TE: Need to add custom pin to both of these*/
            formsMap.CustomPins.Add(newEventPin);
            formsMap.Pins.Add(newEventPin);
            /*TE: Shows button on map to use this location*/
            formsMap.CreatePinButton();
        }
        public async void OnAppearing()
        {
            Map.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(0, 0), Distance.FromMeters(10000000)));
            Location loc = await Geolocation.GetLocationAsync();

            Map.CustomPins.Clear();
            Map.Pins.Clear();

            Services.RestService connection = new Services.RestService();
            (List <Guide> guides, int statuscode) = await connection.GetPublishedGuides();

            if (statuscode == 200)
            {
                //Map.CustomPins = new List<CustomPin>();
                foreach (Guide guide in guides)
                {
                    CustomPin location = new CustomPin
                    {
                        Type     = PinType.Place,
                        Position = new Position(guide.latitude, guide.longitude),
                        Label    = guide.title,                            //Titulo label
                        Address  = guide.creator_username,                 //Persona snippet
                        Name     = Math.Round(guide.rating, 1).ToString(), //Rating
                        Url      = guide._id
                    };
                    Map.CustomPins.Add(location);
                    Map.Pins.Add(location);
                }
            }
            await Task.Delay(2000);

            Map.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(loc.Latitude, loc.Longitude), Distance.FromMeters(1500000)));
        }
예제 #25
0
        public MapPageCS()
        {
            var customMap = new CustomMap
            {
                MapType       = MapType.Street,
                WidthRequest  = App.ScreenWidth,
                HeightRequest = App.ScreenHeight
            };

            var pin = new CustomPin
            {
                Type     = PinType.Place,
                Position = new Position(16.752966, -93.106369),
                Label    = "Tuxtla Gutiérrez",
                Address  = "Chiapas",
                Id       = "Xamarin",
                Url      = "http://xamarin.com/about/"
            };

            customMap.CustomPins = new List <CustomPin> {
                pin
            };
            customMap.Pins.Add(pin);
            customMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(16.752966, -93.106369), Distance.FromMiles(1.0)));

            Content = customMap;
        }
예제 #26
0
        private void AddFromPushPin(MapControl mapControl, CustomPin from)
        {
            // Reset previous From pushpin
            var fromMapIcon = _tempMapIcons
                              .FirstOrDefault(p => p.MapIcon.Image == FromResource);

            if (fromMapIcon != null)
            {
                fromMapIcon.MapIcon.Image = NormalResource;
            }

            // Set new From pushpin
            if (from != null)
            {
                from.Type = CustomPin.AnnotationType.From;

                var newMapIcon = _tempMapIcons
                                 .FirstOrDefault(p =>
                                                 p.MapIcon.Location.Position.Latitude == from.Position.Latitude &&
                                                 p.MapIcon.Location.Position.Longitude == from.Position.Longitude);

                if (newMapIcon != null)
                {
                    newMapIcon.MapIcon.Image = FromResource;
                }
            }

            ClearPushPins(mapControl);
            AddPushPins(mapControl, _tempMapIcons);
        }
예제 #27
0
        private void DisplayTrucksOnMap(FoodTrucks fTrucks)
        {
            List <CustomPin> customPins = new List <CustomPin>();
            int numOfTrucksAvailable    = fTrucks.foodTrucks.Length;

            // Log.Debug(tag, "Found " + numOfTrucksAvailable + " Trucks.");

            for (int i = 0; i < numOfTrucksAvailable; i++)
            {
                string cuisinCategory = DataTranslateCuisineCategory(fTrucks, i);
                // Log.Debug(tag, "Truck number " + i + " cuisine category: " + cuisinCategory);

                string mealType = DataTranslateMealType(fTrucks, i);
                //  Log.Debug(tag, "Truck number " + i + " meal type: " + mealType);

                var pin = new CustomPin
                {
                    Type     = PinType.Place,
                    Position = new Position(fTrucks.foodTrucks[i].latitude, fTrucks.foodTrucks[i].longitude),
                    Label    = fTrucks.foodTrucks[i].name + "\nCuisine Category: " + cuisinCategory + "\nMeal Type: " + mealType,
                    Id       = "FoodTruck" + i,
                    Url      = "google.com"
                };

                customPins.Add(pin);
                customMap.CustomPins = customPins;
                customMap.Pins.Add(pin);
            }
        }
예제 #28
0
        private void AddToPushPin(MapControl mapControl, CustomPin to)
        {
            // Reset previous To pushpin
            var toMapIcon = _tempMapIcons
                            .FirstOrDefault(p => p.MapIcon.Image == ToResource);

            if (toMapIcon != null)
            {
                toMapIcon.MapIcon.Image = NormalResource;
            }

            // Set new To pushpin
            if (to != null)
            {
                to.Type = CustomPin.AnnotationType.To;

                var newMapIcon = _tempMapIcons
                                 .FirstOrDefault(p =>
                                                 p.MapIcon.Location.Position.Latitude == to.Position.Latitude &&
                                                 p.MapIcon.Location.Position.Longitude == to.Position.Longitude);

                if (newMapIcon != null)
                {
                    newMapIcon.MapIcon.Image = ToResource;
                }
            }

            ClearPushPins(mapControl);
            AddPushPins(mapControl, _tempMapIcons);
        }
        /// <summary>
        /// This function creates 1 pin at a location on the map.
        /// </summary>
        /// <param name="latitude">The laatitude we will place it at</param>
        /// <param name="longitude">The longitude we will place it at</param>
        void CreateLocationPin(double latitude, double longitude)
        {
            var formsMap = Element as CustomMap;

            /*TE: Clear all existing pins. We do not want event pins to be shown on the map and we do not want two location selection pins either. Its a hack but it works.*/
            customPins.Clear();
            Map.Pins.Clear();
            formsMap.selectedLatitude  = latitude;
            formsMap.selectedLongitude = longitude;
            /*TE: Show button to use this location*/
            formsMap.CreatePinButton();

            CustomPin newEventPin = new CustomPin
            {
                Id              = "Xamarin",
                Type            = PinType.Place,
                Position        = new Xamarin.Forms.Maps.Position(latitude, longitude),
                Label           = "Location Pin",
                Address         = "Use This Location for Event",
                Url             = "EventDetailsPage",
                BuildingName    = "",
                EventTime       = "",
                foodFinderEvent = null
            };

            /*TE: Need to add to both pin lists or they will not show up. Map.Pins is where there are taken from to place on the map, custom pins is used for the extra info in the info popups.*/
            customPins.Add(newEventPin);
            Map.Pins.Add(newEventPin);

            Console.WriteLine("Location Pin Added!");
        }
예제 #30
0
        private void drawPins(IEnumerable <VLCMonument> monuments)
        {
            //MÉTODP QUE RECIBE COMO PARÁMETRO LOS MONUMENTOS QUE SERÁN DIBUJADOS EN EL MAPA
            List <CustomPin> listPin = new List <CustomPin>();

            //RECORRIDO DE LISTADO Y POR CADA UNO CONVIERTE LAS COORDENADAS Y CREA UN PIN QUE COLOCARÁ EN EL MAPA
            foreach (var monument in monuments)
            {
                UniversalTransverseMercator utm = new UniversalTransverseMercator("S", 30, monument.Coordinates[0], monument.Coordinates[1]);
                Coordinate c = UniversalTransverseMercator.ConvertUTMtoLatLong(utm);

                Xamarin.Forms.Maps.Position position = new Xamarin.Forms.Maps.Position(c.Latitude.DecimalDegree, c.Longitude.DecimalDegree);
                map.MoveToRegion(MapSpan.FromCenterAndRadius(position, Xamarin.Forms.Maps.Distance.FromMiles(.5)));

                var pin = new CustomPin
                {
                    Type     = PinType.Place,
                    Position = new Xamarin.Forms.Maps.Position(c.Latitude.DecimalDegree, c.Longitude.DecimalDegree),
                    Label    = monument.Nombre,
                    Icon     = monument.Imagen.Substring(0, monument.Imagen.Length - 4),
                };
                listPin.Add(pin);

                map.Pins.Add(pin);
            }
            map.CustomPins = listPin;
        }
 public XamarinMapOverlay(CustomPin pin)
 {
     this.InitializeComponent();
     customPin = pin;
     SetupData();   
 }