Пример #1
0
        public MapPage()
        {
            var customMap = new CustomMap
            {
                MapType = MapType.Street,
                WidthRequest = App.ScreenWidth,
                HeightRequest = App.ScreenHeight
            };

            geoCoder = new Geocoder ();

            var locator = CrossGeolocator.Current;
            locator.DesiredAccuracy = 50;

            locator.GetPositionAsync (timeoutMilliseconds: 10000).ContinueWith (t => {

                var pin = new CustomPin {
                    Pin = new Pin {
                        Type = PinType.Place,
                        Position = new Xamarin.Forms.Maps.Position (t.Result.Latitude, t.Result.Longitude),
                        Label = "Ma Position",
                        //Address = "394 Pacific Ave, San Francisco CA"
                    },
                    Name = "Xam",
                    Id = "Xamarin"
                };

                customMap.CustomPins = new List<CustomPin> { pin };
                customMap.Pins.Add (pin.Pin);
                customMap.MoveToRegion (MapSpan.FromCenterAndRadius (new Xamarin.Forms.Maps.Position (t.Result.Latitude, t.Result.Longitude), Distance.FromMiles (0.3)));

                Content = customMap;
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
Пример #2
0
        public MapPageCS()
        {
            var customMap = new CustomMap
            {
                MapType       = MapType.Street,
                WidthRequest  = App.ScreenWidth,
                HeightRequest = App.ScreenHeight
            };

            var pin = new CustomPin
            {
                Pin = new Pin
                {
                    Type     = PinType.Place,
                    Position = new Position(32.754795, -97.331384),
                    Label    = "Xamarin San Francisco Office",
                    Address  = "Sundance Square, Fortworth TX"
                },
                Id  = "Xamarin",
                Url = "http://xamarin.com/about/"
            };

            customMap.CustomPins = new List <CustomPin> {
                pin
            };
            customMap.Pins.Add(pin.Pin);
            customMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(32.754795, -97.331384), Distance.FromMiles(0.08)));

            Content = customMap;
        }
Пример #3
0
        public MapsPage()
        {
            InitializeComponent();
            var mp = new CustomMap();

            var pin = new CustomPin
            {
                Type       = PinType.Place,
                Position   = new Position(37.79752, -122.40183),
                Label      = "YMCA",
                Address    = "394 Pacific Ave, San Francisco CA",
                Id         = "Xamarin",
                Url        = "http://ymca.org",
                streetview = "Abhishek"
            };
            var pin2 = new CustomPin
            {
                Type       = PinType.Place,
                Position   = new Position(37.79500, -122.40000),
                Label      = "YMCA San Francisco Office",
                Address    = "394 Pacific Ave, San Francisco CA",
                Id         = "Xamarin",
                Url        = "https://www.google.com/maps/@33.2249104,-117.2909954,3a,90y,-4.81h,88.84t/data=!3m6!1e1!3m4!1sAF1QipNJoAGctctHWEOcli2MR1SkS2dGySR7OxaHMlmT!2e10!7i13312!8i6656",
                streetview = "my home"
            };

            mp.CustomPins = new List <CustomPin> {
                pin, pin2
            };
            foreach (var item in mp.CustomPins)
            {
                mp.Pins.Add(item);
            }



            mp.MoveToRegion(MapSpan.FromCenterAndRadius(
                                new Position(37.79752, -122.40183), Distance.FromMiles(1.0)));

            Content = mp;
        }