protected override void AddOverlays()
        {
            base.AddOverlays();
            /* Itemized Overlay */
            /* Create a static ItemizedOverlay showing some Markers on various cities. */

            var context = Activity;

            _myLocationOverlay = new MyLocationNewOverlay(context, new GpsMyLocationProvider(context), mapView);

            var items = new List <OverlayItem>
            {
                new OverlayItem("Moj Dom!", "Morsko ul. Zamkowa 25", new GeoPoint(50.54457, 19.50684)),
            };
            //19.50684
            /* OnTapListener for the Markers, shows a simple Toast. */
            var overlay = new ItemizedOverlayWithFocus(items, new OnItemGestureListener(Application.Context), ResourceProxy);
            //int resID = Resources.GetIdentifier(Resources, "drawcheese_1",);
            Drawable newMarker = new Drawable();

            // newMarker = Resources.GetDrawable(Resource.Drawable.cheese_1);
            overlay.SetFocusItemsOnTap(true);
            overlay.SetFocusedItem(0);
            mapView.Overlays.Add(_myLocationOverlay);
            _myLocationOverlay.EnableMyLocation();
            _myLocationOverlay.EnableFollowLocation();



            mapView.Overlays.Add(overlay);

            var rotationGestureOverlay = new RotationGestureOverlay(Activity, mapView)
            {
                Enabled = false
            };

            mapView.Overlays.Add(rotationGestureOverlay);

            /* MiniMap */
            var miniMapOverlay = new MinimapOverlay(Activity, mapView.TileRequestCompleteHandler);

            mapView.Overlays.Add(miniMapOverlay);

            // Zoom and center on the focused item.
            mapView.Controller.SetZoom(50);
            // var geoPoint = ((OverlayItem) overlay.FocusedItem).Point;
            // mapView.Controller.AnimateTo(geoPoint);
            //mapView.Controller.AnimateTo(_myLocationOverlay.MyLocation);

            //  HasOptionsMenu = true;
        }
コード例 #2
0
        public override void OnActivityCreated(Bundle savedInstanceState)
        {
            base.OnActivityCreated(savedInstanceState);

            var context = Activity;
            var dm      = context.Resources.DisplayMetrics;

            // mResourceProxy = new ResourceProxyImpl(getActivity().getApplicationContext());

            _prefs = context.GetSharedPreferences(OpenStreetMapConstants.PrefsName, FileCreationMode.Private);

            _compassOverlay = new CompassOverlay(context, new InternalCompassOrientationProvider(context),
                                                 _mapView);
            _myLocationOverlay = new MyLocationNewOverlay(context, new GpsMyLocationProvider(context),
                                                          _mapView);

            _minimapOverlay = new MinimapOverlay(Activity, _mapView.TileRequestCompleteHandler)
            {
                Width  = dm.WidthPixels / 5,
                Height = dm.HeightPixels / 5
            };

            _scaleBarOverlay = new ScaleBarOverlay(context);
            _scaleBarOverlay.SetCentred(true);
            _scaleBarOverlay.SetScaleBarOffset(dm.WidthPixels / 2, 10);

            _rotationGestureOverlay = new RotationGestureOverlay(context, _mapView)
            {
                Enabled = false
            };

            _mapView.SetBuiltInZoomControls(true);
            _mapView.SetMultiTouchControls(true);
            _mapView.Overlays.Add(_myLocationOverlay);
            _mapView.Overlays.Add(_compassOverlay);
            _mapView.Overlays.Add(_minimapOverlay);
            _mapView.Overlays.Add(_scaleBarOverlay);
            _mapView.Overlays.Add(_rotationGestureOverlay);

            _mapView.Controller.SetZoom(_prefs.GetInt(OpenStreetMapConstants.PrefsZoomLevel, 1));
            _mapView.ScrollTo(_prefs.GetInt(OpenStreetMapConstants.PrefsScrollX, 0),
                              _prefs.GetInt(OpenStreetMapConstants.PrefsScrollY, 0));

            _myLocationOverlay.EnableMyLocation();
            _compassOverlay.EnableCompass();

            HasOptionsMenu = true;
        }
コード例 #3
0
        public override void OnActivityCreated(Bundle savedInstanceState)
        {
            base.OnActivityCreated(savedInstanceState);

            var context = Activity;
            var dm = context.Resources.DisplayMetrics;
            // mResourceProxy = new ResourceProxyImpl(getActivity().getApplicationContext());

            _prefs = context.GetSharedPreferences(OpenStreetMapConstants.PrefsName, FileCreationMode.Private);

            _compassOverlay = new CompassOverlay(context, new InternalCompassOrientationProvider(context),
                _mapView);
            _myLocationOverlay = new MyLocationNewOverlay(context, new GpsMyLocationProvider(context),
                _mapView);

            _minimapOverlay = new MinimapOverlay(Activity, _mapView.TileRequestCompleteHandler)
            {
                Width = dm.WidthPixels/5,
                Height = dm.HeightPixels/5
            };

            _scaleBarOverlay = new ScaleBarOverlay(context);
            _scaleBarOverlay.SetCentred(true);
            _scaleBarOverlay.SetScaleBarOffset(dm.WidthPixels/2, 10);

            _rotationGestureOverlay = new RotationGestureOverlay(context, _mapView) {Enabled = false};

            _mapView.SetBuiltInZoomControls(true);
            _mapView.SetMultiTouchControls(true);
            _mapView.Overlays.Add(_myLocationOverlay);
            _mapView.Overlays.Add(_compassOverlay);
            _mapView.Overlays.Add(_minimapOverlay);
            _mapView.Overlays.Add(_scaleBarOverlay);
            _mapView.Overlays.Add(_rotationGestureOverlay);

            _mapView.Controller.SetZoom(_prefs.GetInt(OpenStreetMapConstants.PrefsZoomLevel, 1));
            _mapView.ScrollTo(_prefs.GetInt(OpenStreetMapConstants.PrefsScrollX, 0),
                _prefs.GetInt(OpenStreetMapConstants.PrefsScrollY, 0));

            _myLocationOverlay.EnableMyLocation();
            _compassOverlay.EnableCompass();

            HasOptionsMenu = true;
        }
コード例 #4
0
        private void InitMapView()
        {
            var mapView = FindViewById<MapView>(R.Id.mapView);  // mapPath

            ITileSource tileSource = TileSourceFactory.Mapnik;

            mapView.SetTileSource(tileSource);
            mapView.TilesScaledToDpi = true;
            mapView.SetMultiTouchControls(true);
            mapView.Zoom += mapView_Zoom;
            mapView.Scroll += mapView_Scroll;

            //---------------���õ�ͼ��ת-------------------
            //_mRotationGestureOverlay = new RotationGestureOverlay(this, mapView);
            //_mRotationGestureOverlay.Enabled = true;
            //mapView.Overlays.Add(_mRotationGestureOverlay);

            mapController = mapView.Controller;
            mapController.SetZoom(15);
            GeoPoint startPoint = new GeoPoint(30.538079, 114.4159972);
            mapController.SetCenter(startPoint);

            DefaultResourceProxyImpl resourceProxy = new DefaultResourceProxyImpl(this);
            myLocationoverlay = new MyLocationNewOverlay(this, new GpsMyLocationProvider(this), mapView);
            myLocationoverlay.EnableMyLocation(); // not on by default
            myLocationoverlay.RunOnFirstFix(this);
            mapView.Overlays.Add(myLocationoverlay);
            _mapView = mapView;
        }