private void showUserMap()
        {
            map.MapType           = MKMapType.HybridFlyover;
            map.ShowsUserLocation = true;
            map.ZoomEnabled       = true;
            map.ScrollEnabled     = true;
            map.ShowsBuildings    = true;
            map.PitchEnabled      = true;
            map.ShowsCompass      = false;
            double lat = 30.2652233534254;
            double lon = -97.73815460962083;
            CLLocationCoordinate2D mapCenter = new CLLocationCoordinate2D(lat, lon);
            CLLocationCoordinate2D viewPoint = new CLLocationCoordinate2D(lat + 0.0050, lon - 0.0072);
            MKCoordinateRegion     mapRegion = MKCoordinateRegion.FromDistance(mapCenter, 1500, 1500);

            map.CenterCoordinate = mapCenter;
            map.Region           = mapRegion;
            var camera = MKMapCamera.CameraLookingAtCenterCoordinate(mapCenter, viewPoint, 500);

            map.Camera   = camera;
            mapDelegate  = new MapDelegate();
            map.Delegate = mapDelegate;
            askUserPermissions();

            var tapRecogniser     = new UITapGestureRecognizer(this, new Selector("MapTapSelector:"));
            var longTapRecogniser = new UILongPressGestureRecognizer(this, new Selector("MapLongTapSelector:"));

            map.AddGestureRecognizer(tapRecogniser);
            map.AddGestureRecognizer(longTapRecogniser);
            var hotelOverlay = MKCircle.Circle(mapCenter, 1000);

            map.AddOverlay(hotelOverlay);
        }
Beispiel #2
0
        //UIView customPinView;
        //bool animando = false;

        protected override void OnElementChanged(ElementChangedEventArgs <View> e)
        {
            base.OnElementChanged(e);
            var map = e.NewElement;

            if (e.OldElement != null)
            {
                _nativeMap = Control as MKMapView;
                //_nativeMap.GetViewForAnnotation = null;
            }

            if (e.NewElement != null)
            {
                //RadarPin radar = new RadarPin();
                //RadarMKAnnotation radarMKAnnotation = new RadarMKAnnotation(radar);
                _radarMap = (RadarMap)e.NewElement;
                //SetNativeControl(new MKMapView(CGRect.Empty));
                _nativeMap = Control as MKMapView;
                //MeuCustomPin customPin = new MeuCustomPin();
                //_nativeMap.Delegate = customPin;
                //_nativeMap.AddAnnotation(new MKPointAnnotation()
                //{
                //	Coordinate = new CLLocationCoordinate2D(radar.Pin.Position.Latitude, radar.Pin.Position.Longitude)
                //});
                //_nativeMap.GetViewForAnnotation = GetViewForAnnotation;
                _radarMap.AoAtualizaPosicao += (object sender, LocalizacaoInfo local) => {
                    CLLocationCoordinate2D target = new CLLocationCoordinate2D(local.Latitude, local.Longitude);

                    MKMapCamera camera = MKMapCamera.CameraLookingAtCenterCoordinate(target, PreferenciaUtils.NivelZoom, local.Sentido, local.Sentido);
                    _nativeMap.Camera = camera;
                    //MKCoordinateRegion mapRegion = MKCoordinateRegion.FromDistance(target, 100, 100);
                    //_nativeMap.CenterCoordinate = target;
                    //_nativeMap.Region = mapRegion;
                    _nativeMap.ZoomEnabled = true;
                    //_nativeMap.ShowsUserLocation = true;
                    //MeuCustomPin customPin = new MeuCustomPin();

                    _nativeMap.UserInteractionEnabled = PreferenciaUtils.RotacionarMapa;

                    //_nativeMap.UserInteractionEnabled = false;

                    /*
                     * if (!animando)
                     * {
                     *  if (map == null)
                     *      return;
                     *  CameraPosition.Builder builder = CameraPosition.InvokeBuilder(map.CameraPosition);
                     *  builder.Target(new LatLng(local.Latitude, local.Longitude));
                     *  builder.Bearing(local.Sentido);
                     *  builder.Zoom(Configuracao.MapaZoom);
                     *  builder.Tilt(Configuracao.MapaTilt);
                     *  CameraPosition cameraPosition = builder.Build();
                     *  CameraUpdate cameraUpdate = CameraUpdateFactory.NewCameraPosition(cameraPosition);
                     *  map.AnimateCamera(cameraUpdate);
                     *  animando = true;
                     * }
                     */
                };
                _radarMap.AoDesenharRadar += (object sender, RadarPin radar) => {
                    var marker = new MKPointAnnotation()
                    {
                        Coordinate = new CoreLocation.CLLocationCoordinate2D(radar.Pin.Position.Latitude, radar.Pin.Position.Longitude),
                        Title      = radar.Pin.Label,
                        Subtitle   = radar.Pin.Address
                    };

                    _nativeMap.AddAnnotation(marker);
                    desenharRadar(radar);
                };
            }
        }