protected bool LoadNutiteqMapCommon()
        {
            // Set base projection
            EPSG3857 proj = new EPSG3857();

            _mapViewer.Options.BaseProjection = proj; // note: EPSG3857 is the default, so this is actually not required

            // Set initial location and other parameters, don't animate
            _mapViewer.FocusPos    = proj.FromWgs84(new MapPos(-0.8164, 51.2383)); // Berlin
            _mapViewer.Zoom        = 2;
            _mapViewer.MapRotation = 0;
            _mapViewer.Tilt        = 90;

            // Start package manager
            var packageManager = new NutiteqPackageManager("nutiteq.mbstreets", _downloadPackagePath);

            packageManager.Start();

            // Import initial package
            if (packageManager.GetLocalPackage("world0_4") == null)
            {
                packageManager.StartPackageImport("world0_4", 1, _importPackagePath);
            }

            // Set bounding box
            String bbox = "bbox(-0.8164,51.2382,0.6406,51.7401)"; // London (about 30MB)

            if (packageManager.GetLocalPackage(bbox) == null)
            {
                packageManager.StartPackageDownload(bbox);
            }

            // Now can add vector map as layer
            // define styling for vector map
            UnsignedCharVector  styleBytes        = AssetUtils.LoadBytes("osmbright.zip");
            MBVectorTileDecoder vectorTileDecoder = null;

            if (styleBytes != null)
            {
                // Create style set
                MBVectorTileStyleSet vectorTileStyleSet = new MBVectorTileStyleSet(styleBytes);
                vectorTileDecoder = new MBVectorTileDecoder(vectorTileStyleSet);
            }
            else
            {
                Log.Error("Failed to load style data");
            }

            // Create online base layer (no package download needed then). Use vector style from assets (osmbright.zip)
            // comment in to use online map. Packagemanager stuff is not needed then
            //			VectorTileLayer baseLayer = new NutiteqOnlineVectorTileLayer("osmbright.zip");

            var baseLayer = new VectorTileLayer(new PackageManagerTileDataSource(packageManager), vectorTileDecoder);

            _mapViewer.Layers.Add(baseLayer);

            return(true);
        }
        protected bool LoadNutiteqMapCommon()
        {
            // Set base projection
            EPSG3857 proj = new EPSG3857();
            _mapViewer.Options.BaseProjection = proj; // note: EPSG3857 is the default, so this is actually not required

            // Set initial location and other parameters, don't animate
            _mapViewer.FocusPos = proj.FromWgs84(new MapPos(-0.8164, 51.2383)); // Berlin
            _mapViewer.Zoom = 2;
            _mapViewer.MapRotation = 0;
            _mapViewer.Tilt = 90;

            // Start package manager
            var packageManager = new NutiteqPackageManager("nutiteq.mbstreets", _downloadPackagePath);
            packageManager.Start();

            // Import initial package
            if (packageManager.GetLocalPackage("world0_4") == null)
            {
                packageManager.StartPackageImport("world0_4", 1, _importPackagePath);
            }

            // Set bounding box
            String bbox = "bbox(-0.8164,51.2382,0.6406,51.7401)"; // London (about 30MB)
            if (packageManager.GetLocalPackage(bbox) == null)
            {
                packageManager.StartPackageDownload(bbox);
            }

            // Now can add vector map as layer
            // define styling for vector map
            UnsignedCharVector styleBytes = AssetUtils.LoadBytes("osmbright.zip");
            MBVectorTileDecoder vectorTileDecoder = null;
            if (styleBytes != null)
            {
                // Create style set
                MBVectorTileStyleSet vectorTileStyleSet = new MBVectorTileStyleSet(styleBytes);
                vectorTileDecoder = new MBVectorTileDecoder(vectorTileStyleSet);
            }
            else
            {
                Log.Error("Failed to load style data");
            }

            // Create online base layer (no package download needed then). Use vector style from assets (osmbright.zip)
            // comment in to use online map. Packagemanager stuff is not needed then
            //			VectorTileLayer baseLayer = new NutiteqOnlineVectorTileLayer("osmbright.zip");

            var baseLayer = new VectorTileLayer(new PackageManagerTileDataSource(packageManager), vectorTileDecoder);
            _mapViewer.Layers.Add(baseLayer);

            return true;
        }
Exemple #3
0
        public static void InitializePackageManager(string packageFolder, string importPackagePath, IMapView mapView, string downloadedPackage)
        {
            // offline base layer

            // 2. define listener, definition is in same class above
            var packageManager = new NutiteqPackageManager("nutiteq.osm", packageFolder);

            packageManager.PackageManagerListener = new PackageListener(packageManager, downloadedPackage);

            // Download new package list only if it is older than 24h
            // Note: this is only needed if pre-made packages are used
            if (packageManager.ServerPackageListAge > 24 * 60 * 60)
            {
                packageManager.StartPackageListDownload();
            }

            // start manager - mandatory
            packageManager.Start();

            // Import initial package
            if (packageManager.GetLocalPackage("world0_4") == null)
            {
                packageManager.StartPackageImport("world0_4", 1, importPackagePath);
            }

            // Now can add vector map as layer
            // define styling for vector map
            UnsignedCharVector  styleBytes        = AssetUtils.LoadBytes("nutibright-v2a.zip");
            MBVectorTileDecoder vectorTileDecoder = null;

            if (styleBytes != null)
            {
                // Create style set
                MBVectorTileStyleSet vectorTileStyleSet = new MBVectorTileStyleSet(styleBytes);
                vectorTileDecoder = new MBVectorTileDecoder(vectorTileStyleSet);
            }
            else
            {
                Log.Error("Failed to load style data");
            }

            // Create online base layer (no package download needed then). Use vector style from assets (osmbright.zip)
            // comment in to use online map. Packagemanager stuff is not needed then
            //			VectorTileLayer baseLayer = new NutiteqOnlineVectorTileLayer("osmbright.zip");

            var baseLayer = new VectorTileLayer(new PackageManagerTileDataSource(packageManager), vectorTileDecoder);

            mapView.Layers.Add(baseLayer);
        }