Beispiel #1
0
        // when pin info window is clicked, change color and then call pop up info method:
        private async Task pinClickedAsync(CustomPin pin, CustomMap customMap)
        {
            string   address    = pin.Label;
            string   cityState  = pin.Address;
            Position p          = pin.Position;
            bool     isLocation = pin.isYourLocation;

            System.Diagnostics.Debug.WriteLine(address + " " + cityState);
            customMap.Pins.Remove(pin);

            var newPin = new CustomPin
            {
                Type     = PinType.Place,
                Position = p,
                Label    = address,
                Address  = cityState,
                // Id = "hasClicked",
                Url            = "http://xamarin.com/about/",
                isYourLocation = isLocation,
                hasClicked     = true
            };

            newPin.Clicked += async(sender, args) => { popUpInfoAsync(address, cityState); };
            customMap.Pins.Add(newPin);
            await popUpInfoAsync(address, cityState);
        }
Beispiel #2
0
        public async Task createPinAsync(CustomMap customMap, double lat1, double lon1, bool isLocation, String address, String cityState)
        {
            try
            {
                var locations = await Geocoding.GetLocationsAsync(address + " " + cityState);

                var location = locations?.FirstOrDefault();
                if (location != null)
                {
                    lat1 = location.Latitude;
                    lon1 = location.Longitude;
                }
                var pin = new CustomPin
                {
                    Type     = PinType.Place,
                    Position = new Position(lat1, lon1),
                    Label    = address,
                    Address  = cityState,
                    // Id = id,
                    isYourLocation = isLocation,
                    Url            = "http://xamarin.com/about/",
                    hasClicked     = false
                };
                pin.Clicked += async(sender, args) => { pinClickedAsync(pin, customMap); };
                customMap.Pins.Add(pin);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString() + "Error with converting address to coordinates");
            }
        }