protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // hide title bar.
            this.RequestWindowFeature(global::Android.Views.WindowFeatures.NoTitle);

            // initialize OsmSharp native handlers.
            Native.Initialize();

            // initialize map.
            var map = new Map();

            // add a preprocessed vector data file.
            var sceneStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(@"Android.Vectors.default.map");
            map.AddLayer(new LayerScene(Scene2D.Deserialize(sceneStream, true)));

            // define the mapview.
            _mapView = new MapView(this, new MapViewSurface(this));
            _mapView.Map = map;
            _mapView.MapMaxZoomLevel = 17; // limit min/max zoom, the vector data in this sample covers only a small area.
            _mapView.MapMinZoomLevel = 12;
            _mapView.MapTilt = 0;
            _mapView.MapCenter = new GeoCoordinate(51.26361, 4.78620);
            _mapView.MapZoom = 16;
            _mapView.MapAllowTilt = false;

            // set the map view as the default content view.
            SetContentView(_mapView);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            this.RequestWindowFeature(global::Android.Views.WindowFeatures.NoTitle);

            var map = new Map();
            map.AddLayer(
                new LayerMBTile(
                    SQLiteConnection.CreateFrom(
                        Assembly.GetExecutingAssembly()
                            .GetManifestResourceStream(@"LainLadangLainBelalang.kempen.mbtiles"), "map")));

            var mvs = new MapViewSurface(this);
            _mv = new MapView(this, mvs)
            {
                Map = map,
                MapMaxZoomLevel = 17,
                MapMinZoomLevel = 12,
                MapTilt = 0,
                MapCenter = new GeoCoordinate(51.26361, 4.78620),
                MapZoom = 16,
                MapAllowTilt = false
            };

            SetContentView(_mv);
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // hide title bar.
            this.RequestWindowFeature(global::Android.Views.WindowFeatures.NoTitle);

            // initialize OsmSharp native handlers.
            Native.Initialize();

            // initialize map.
            var map = new Map();

            // add MBTiles Layer.
            // any stream will do or any path on the device to a MBTiles SQLite databas
            // in this case the data is taken from the resource stream, written to disk and then opened.
            map.AddLayer(new LayerMBTile(SQLiteConnection.CreateFrom(
                Assembly.GetExecutingAssembly().GetManifestResourceStream(@"Android.MBTiles.kempen.mbtiles"), "map")));

            // define the mapview.
            _mapView = new MapView(this, new MapViewSurface(this));
            _mapView.Map = map;
            _mapView.MapMaxZoomLevel = 17; // limit min/max zoom because MBTiles sample only contains a small portion of a map.
            _mapView.MapMinZoomLevel = 12;
            _mapView.MapTilt = 0;
            _mapView.MapCenter = new GeoCoordinate(51.26361, 4.78620);
            _mapView.MapZoom = 16;
            _mapView.MapAllowTilt = false;

            // set the map view as the default content view.
            SetContentView(_mapView);
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // hide title bar.
            this.RequestWindowFeature(global::Android.Views.WindowFeatures.NoTitle);

            // initialize OsmSharp native handlers.
            Native.Initialize();

            // initialize map.
            var map = new Map();

            // add tile Layer.
            // WARNING: Always look at usage policies!
            // WARNING: Don't use my tiles, it's a free account and will shutdown when overused!
            map.AddLayer(new LayerTile("http://a.tiles.mapbox.com/v3/osmsharp.i8ckml0l/{0}/{1}/{2}.png"));

            // define the mapview.
            _mapView = new MapView(this, new MapViewSurface(this));
            _mapView.Map = map;
            _mapView.MapMaxZoomLevel = 18; // limit min/max zoom.
            _mapView.MapMinZoomLevel = 0;
            _mapView.MapTilt = 0;
            _mapView.MapCenter = new GeoCoordinate(21.38, -157.782);
            _mapView.MapZoom = 12;
            _mapView.MapAllowTilt = false;

            // set the map view as the default content view.
            SetContentView(_mapView);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            this.RequestWindowFeature(global::Android.Views.WindowFeatures.NoTitle);

            Native.Initialize();

            var map = new Map();

            map.AddLayer(new LayerTile("https://a.tiles.mapbox.com/v4/yayapiyik.ong4bh3p/page.html?access_token=pk.eyJ1IjoieWF5YXBpeWlrIiwiYSI6ImNpaXE1Ym9ycDAxenh1ZGtuMGM4aXZsY3AifQ.eabfA1EaL4f_Z_QgMEcl-g"));
            /* map.AddLayer(new LayerTile("https://a.tiles.mapbox.com/v4/yayapiyik.ong4bh3p/page.html?access_token=pk.eyJ1IjoieWF5YXBpeWlrIiwiYSI6ImNpaXE1Ym9ycDAxenh1ZGtuMGM4aXZsY3AifQ.eabfA1EaL4f_Z_QgMEcl-g#17/-6.22325/106.65267"));
            */

            mv = new MapView(this, new MapViewSurface(this))
            {
                Map = map,
                MapMaxZoomLevel = 18,
                MapMinZoomLevel = 0,
                MapTilt = 0,
                MapCenter = new GeoCoordinate(-6.22325, 106.65267),
                MapZoom = 12,
                MapAllowTilt = false
            };

            SetContentView(mv);
        }
        protected override void OnDestroy()
        {
            base.OnDestroy();

            // dispose of all resources.
            // the mapview is completely destroyed in this sample, read about the Android Activity Lifecycle here:
            // http://docs.xamarin.com/guides/android/application_fundamentals/activity_lifecycle/
            _mapView.Map.Close();

            _mapView.Close();
            _mapView.Dispose();
            _mapView = null;
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // hide title bar.
            this.RequestWindowFeature(global::Android.Views.WindowFeatures.NoTitle);

            // initialize map.
            var map = new Map();

            // add a preprocessed vector data file.
            //var sceneStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(@"Android.Demo.default.map");
            //map.AddLayer(new LayerScene(Scene2D.Deserialize(sceneStream, true)));

            //OsmSharp.Osm.Data.Memory.MemoryDataSource dataSource;
            //using (var sceneStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(@"Android.Demo.map1.osm"))
            //{
            //    dataSource = OsmSharp.Osm.Data.Memory.MemoryDataSource.CreateFromXmlStream(sceneStream);
            //}
            string path = Assembly.GetExecutingAssembly().GetName().Name;
            StreamReader streamReader = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream(path + ".EmbeddedResources.default.mapcss"));
            string test = streamReader.ReadToEnd();
            StyleInterpreter styleInterpreter = new OsmSharp.UI.Map.Styles.MapCSS.MapCSSInterpreter(test);
            map.AddLayerOsm(OsmSharp.Osm.Data.Memory.MemoryDataSource.CreateFromXmlStream(Assembly.GetExecutingAssembly().GetManifestResourceStream(path + ".EmbeddedResources.map.osm")), styleInterpreter);

            //var r2d = new CanvasRenderer2D();
            //var renderer = new OsmSharp.UI.Map.MapRenderer<Canvas>(r2d);
            //var view = OsmSharp.UI.Renderer.View2D.CreateFromBounds(dataSource.BoundingBox.TopLeft.Latitude, dataSource.BoundingBox.TopLeft.Longitude,
            //                                             dataSource.BoundingBox.BottomRight.Latitude, dataSource.BoundingBox.BottomRight.Longitude);
            //map.ViewChanged(16, new OsmSharp.Math.Geo.GeoCoordinate(view.Center), null, view);

            // define the mapview.
            var mapViewSurface = new MapViewSurface(this);
            mapViewSurface.MapScaleFactor = 2;
            _mapView = new MapView(this, mapViewSurface);
            _mapView.Map = map;
            _mapView.MapMaxZoomLevel = 17; // limit min/max zoom, the vector data in this sample covers only a small area.
            _mapView.MapMinZoomLevel = 12;
            _mapView.MapTilt = 0;
            //_mapView.MapCenter = new GeoCoordinate(51.26361, 4.78620);
            _mapView.MapCenter = new GeoCoordinate(30.538079, 114.4159972);
            _mapView.MapZoom = 16;
            _mapView.MapAllowTilt = false;

            // set the map view as the default content view.
            SetContentView(_mapView);
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // enable the logging.
            OsmSharp.Logging.Log.Enable();
            OsmSharp.Logging.Log.RegisterListener(new OsmSharp.Android.UI.Log.LogTraceListener());

            // hide title bar.
            this.RequestWindowFeature(global::Android.Views.WindowFeatures.NoTitle);

            // initialize OsmSharp native handlers.
            Native.Initialize();

            // initialize router.
            RouterFacade.Initialize();

            // initialize map.
            var map = new Map();

            // add tile Layer.
            // WARNING: Always look at usage policies!
            // WARNING: Don't use my tiles, it's a free account and will shutdown when overused!
            map.AddLayer(new LayerTile(@"http://otile1.mqcdn.com/tiles/1.0.0/osm/{0}/{1}/{2}.png"));

            // define route layer.
            _routeLayer = new LayerRoute(map.Projection);
            map.AddLayer(_routeLayer);

            // define the mapview.
            var surface = new MapViewSurface(this);
            _mapView = new MapView(this, surface);
            _mapView.Map = map;
            _mapView.MapMaxZoomLevel = 18;
            _mapView.MapMinZoomLevel = 0;
            _mapView.MapTilt = 0;
            _mapView.MapCenter = new GeoCoordinate(51.2631, 4.7872);
            _mapView.MapZoom = 16;
            _mapView.MapAllowTilt = false;

            _mapView.MapTapEvent += _mapView_MapTapEvent;

            // set the map view as the default content view.
            SetContentView(_mapView);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            this.RequestWindowFeature(global::Android.Views.WindowFeatures.NoTitle);

            var map = new Map();
            var sceneStream =
                Assembly.GetExecutingAssembly().GetManifestResourceStream(@"LainLadangLainBelalang.default.map");
            map.AddLayer(new LayerScene(Scene2D.Deserialize(sceneStream, true)));
            var mvs = new MapViewSurface(this);
            _mv = new MapView(this, mvs)
            {
                Map = map,
                MapMaxZoomLevel = 17,
                MapMinZoomLevel = 12,
                MapTilt = 0,
                MapCenter = new GeoCoordinate(51.26361, 4.78620),
                MapZoom = 16,
                MapAllowTilt = false
            };

            SetContentView(_mv);
        }
Beispiel #10
0
        /// <summary>
        /// Initialize implementation from IMapView.
        /// </summary>
        /// <param name="mapLayout"></param>
        void IMapViewSurface.Initialize(MapView mapLayout)
        {
            this.MapAllowPan = true;
            this.MapAllowTilt = true;
            this.MapAllowZoom = true;

            // register default invalidation trigger.
            (this as IInvalidatableMapSurface).RegisterListener(new DefaultTrigger(this));

            _mapView = mapLayout;
            this.SetWillNotDraw(false);
            // this.SetWillNotCacheDrawing(true);

            this.MapMinZoomLevel = 0;
            this.MapMaxZoomLevel = 20;

            // gets the system density.
            _density = global::Android.Content.Res.Resources.System.DisplayMetrics.Density;
            _bufferFactor = _density; // set default scale factor relative to density.

            // create the renderer.
            _renderer = new MapRenderer<global::Android.Graphics.Canvas>(
                new CanvasRenderer2D(1));

            // initialize the gesture detection.
            this.SetOnTouchListener(this);
            _scaleGestureDetector = new ScaleGestureDetector(
                this.Context, this);
            _rotateGestureDetector = new RotateGestureDetector(
                this.Context, this);
            _moveGestureDetector = new MoveGestureDetector(
                this.Context, this);
            _tagGestureDetector = new TapGestureDetector(
                this.Context, this);

            _makerLayer = new LayerPrimitives(
                new WebMercator());

            // initialize all the caching stuff.
            _backgroundColor = SimpleColor.FromKnownColor(KnownColor.White).Value;
            _cacheRenderer = new MapRenderer<global::Android.Graphics.Canvas>(
                new CanvasRenderer2D(1));
        }
Beispiel #11
0
        /// <summary>
        /// Initialize implementation from IMapView.
        /// </summary>
        /// <param name="mapLayout"></param>
        void IMapViewSurface.Initialize(MapView mapLayout)
        {
            _mapView = mapLayout;
            this.SetWillNotDraw(false);

            this.MapMinZoomLevel = 10;
            this.MapMaxZoomLevel = 20;

            _renderer = new MapRenderer<global::Android.Graphics.Canvas>(
                new CanvasRenderer2D());

            // initialize the gesture detection.
            this.SetOnTouchListener(this);
            _scaleGestureDetector = new ScaleGestureDetector(
                this.Context, this);
            _rotateGestureDetector = new RotateGestureDetector(
                this.Context, this);
            _moveGestureDetector = new MoveGestureDetector(
                this.Context, this);
            _tagGestureDetector = new TapGestureDetector(
                this.Context, this);

            _makerLayer = new LayerPrimitives(
                new WebMercator());

            // initialize all the caching stuff.
            _cacheRenderer = new MapRenderer<global::Android.Graphics.Canvas>(
                new CanvasRenderer2D());
            _scene = new Scene2DSimple();
            _scene.BackColor = SimpleColor.FromKnownColor(KnownColor.White).Value;

            new Timer(InvalidateSimple, null, 0, 50);
        }
        /// <summary>
        /// Initialize implementation from IMapView.
        /// </summary>
        /// <param name="mapLayout"></param>
        void IMapViewSurface.Initialize(MapView mapLayout)
        {
            // create the Open GL 2D target.
            _target = new OpenGLTarget2D();
            this.SetRenderer(_target);

            _mapView = mapLayout;
            this.SetWillNotDraw(false);

            this.MapMinZoomLevel = 10;
            this.MapMaxZoomLevel = 20;

            // create the renderer.
            _renderer = new MapRenderer<OpenGLTarget2D>(
                    new OpenGLRenderer2D());

            // initialize the gesture detection.
            this.SetOnTouchListener(this);
            _scaleGestureDetector = new ScaleGestureDetector(
                this.Context, this);
            _rotateGestureDetector = new RotateGestureDetector(
                this.Context, this);
            _moveGestureDetector = new MoveGestureDetector(
                this.Context, this);
            _tagGestureDetector = new TapGestureDetector(
                this.Context, this);

            _makerLayer = new LayerPrimitives(
                new WebMercator());

            _scene = new Scene2D(new WebMercator(), 16);
            _scene.BackColor = SimpleColor.FromKnownColor(KnownColor.White).Value;
        }