示例#1
0
        /// <summary>
        /// Raises the OnLoad event.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            // initialize mapcss interpreter.
            var mapCSSInterpreter = new MapCSSInterpreter(
                new FileInfo(@"dark_roads.mapcss").OpenRead(), new MapCSSDictionaryImageSource());

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

            //// initialize router.
            //_router = Router.CreateFrom(new OsmSharp.Osm.PBF.Streams.PBFOsmStreamSource(
            //    new FileInfo(@"kempen.osm.pbf").OpenRead()), new OsmRoutingInterpreter());

            //var scene = new Scene2D(new OsmSharp.Math.Geo.Projections.WebMercator(), new List<float>(new float[] {
            //    16, 14, 12, 10 }));
            //var target = new StyleOsmStreamSceneTarget(
            //    mapCSSInterpreter, scene, new WebMercator());
            //var source = new PBFOsmStreamSource(
            //    new FileInfo(@"kempen.osm.pbf").OpenRead());
            //var progress = new OsmStreamFilterProgress();
            //progress.RegisterSource(source);
            //target.RegisterSource(progress);
            //target.Pull();

            ////var merger = new Scene2DObjectMerger();
            ////scene = merger.BuildMergedScene(scene);

            //map.AddLayer(new LayerScene(scene));
            //var dataSource = MemoryDataSource.CreateFromXmlStream(
            //    new FileInfo(@"D:\Dropbox\Dropbox\SharpSoftware\Projects\Eurostation ReLive\Server_Dropbox\OSM\relive_mechelen\mechelen_new.osm").OpenRead());
            //map.AddLayer(new LayerOsm(dataSource, mapCSSInterpreter, map.Projection));
            var layerTile = new LayerTile(@"http://*****:*****@"default.map").OpenRead(),
            //        true)));

            // initialize route/points layer.
            _layerRoute = new LayerRoute(new OsmSharp.Math.Geo.Projections.WebMercator());
            map.AddLayer(_layerRoute);
            _layerPrimitives = new LayerPrimitives(new OsmSharp.Math.Geo.Projections.WebMercator());
            map.AddLayer(_layerPrimitives);

            // set control properties.
            this.mapControl1.Map = map;
            this.mapControl1.MapCenter = new GeoCoordinate(51.262, 4.7880); // wechel
            this.mapControl1.MapZoom = 14;
            this.mapControl1.MapMouseClick += mapControl1_MapMouseClick;
            this.mapControl1.MapMouseMove += mapControl1_MapMouseMove;
        }
示例#2
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));
        }
        private void frmMain_Load(object sender, EventArgs e)
        {
            var mapCSSInterpreter = new MapCSSInterpreter(new FileInfo(@"dark_roads.mapcss").OpenRead(), new MapCSSDictionaryImageSource());

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

            //// initialize router.
            try
            {
                _router = Router.CreateLiveFrom(new OsmSharp.Osm.PBF.Streams.PBFOsmStreamSource(new FileInfo(@"C:\Users\smccloud\Documents\GitHub\OsmSharp.Service.Tiles\OsmSharp.Service.Tiles.SelfHost\bin\Debug\stcloud.osm.pbf").OpenRead()), new OsmRoutingInterpreter());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            try
            {

                var layerTile = new LayerTile(@"http://localhost:1234/tiles_stcloud/{z}/{x}/{y}.png");
                map.AddLayer(layerTile);
                _layerRoute = new LayerRoute(new OsmSharp.Math.Geo.Projections.WebMercator());
                map.AddLayer(_layerRoute);
                _layerPrimitives = new LayerPrimitives(new OsmSharp.Math.Geo.Projections.WebMercator());
                map.AddLayer(_layerPrimitives);

                // set control properties.
                this.mapControl1.Map = map;
                this.mapControl1.MapCenter = new GeoCoordinate(45.5233, -94.14905);
                this.mapControl1.MapZoom = 14;
                this.mapControl1.Refresh();
                this.mapControl1.MapMouseClick += mapControl1_MapMouseClick;
                this.mapControl1.MapMouseMove += mapControl1_MapMouseMove;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                this.Close();
            }
        }
示例#4
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);
        }
示例#5
0
        /// <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;
        }