public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            // Add default base layer
            AddOnlineBaseLayer(CartoBaseMapStyle.CartoBasemapStylePositron);

            // Initialize a local vector data source
            LocalVectorDataSource source = new LocalVectorDataSource(BaseProjection);

            // Initialize a vector layer with the previous data source
            var layer = new ClusteredVectorLayer(source, new MyClusterElementBuilder());

            // Default is 100. A good value depends on data
            layer.MinimumClusterDistance = 50;

            // read json from assets and add to map
            string json = System.IO.File.ReadAllText(AssetUtils.CalculateResourcePath("cities15000.geojson"));

            // Create a basic style, as the ClusterElementBuilder will set the real style
            var markerStyleBuilder = new MarkerStyleBuilder();

            markerStyleBuilder.Size = 14;
            MarkerStyle style = markerStyleBuilder.BuildStyle();

            // Read GeoJSON, parse it using SDK GeoJSON parser
            GeoJSONGeometryReader reader = new GeoJSONGeometryReader();

            // Set target projection to base (mercator)
            reader.TargetProjection = BaseProjection;

            // Read features from local asset
            FeatureCollection features = reader.ReadFeatureCollection(json);

            VectorElementVector elements = new VectorElementVector();

            for (int i = 0; i < features.FeatureCount; i++)
            {
                // This data set features point geometry,
                // however, it can also be LineGeometry or PolygonGeometry
                PointGeometry geometry = (PointGeometry)features.GetFeature(i).Geometry;
                elements.Add(new Marker(geometry, style));
            }

            // Add the clustered vector layer to the map
            source.AddAll(elements);

            MapView.Layers.Add(layer);
        }
Beispiel #2
0
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            // Set online base layer
            var styleAsset = AssetUtils.LoadAsset("nutibright-v2a.zip");
            var baseLayer  = new CartoOnlineVectorTileLayer("nutiteq.osm", new ZippedAssetPackage(styleAsset));

            MapView.Layers.Add(baseLayer);

            // read json from assets and add to map
            var json = System.IO.File.ReadAllText(AssetUtils.CalculateResourcePath("capitals_3857.geojson"));

            MapSetup.AddJsonLayer(MapView, json);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // GLKViewController-specific parameters for smoother animations
            ResumeOnDidBecomeActive  = false;
            PreferredFramesPerSecond = 60;

            // Register license
            Nutiteq.Utils.Log.ShowError = true;
            Nutiteq.Utils.Log.ShowWarn  = true;
            Nutiteq.Utils.Log.ShowDebug = true;
            Nutiteq.Ui.MapView.RegisterLicense("XTUM0Q0ZRQytoU2xnd0MrZ2kvV0VhUmlWVGYxK0xsbDJNd0lWQUt6Z245R1F5NW95RXJ5WndoejBNcGpDdGpSZgoKcHJvZHVjdHM9c2RrLXhhbWFyaW4taW9zLTMuKgpidW5kbGVJZGVudGlmaWVyPWNvbS5udXRpdGVxLmhlbGxvbWFwLnhhbWFyaW4Kd2F0ZXJtYXJrPW51dGl0ZXEKdXNlcktleT0yYTllOWY3NDYyY2VmNDgxYmUyYThjMTI2MWZlNmNiZAo=");


            // Create package manager folder (Platform-specific)
            var paths       = NSSearchPath.GetDirectories(NSSearchPathDirectory.ApplicationSupportDirectory, NSSearchPathDomain.User);
            var packagesDir = paths [0] + "packages";

            NSFileManager.DefaultManager.CreateDirectory(packagesDir, true, null);


            // Initialize map
            string downloadArea = "bbox(-0.8164,51.2382,0.6406,51.7401)";             // London (about 30MB)
//			string downloadId = "EE"; // one of ID-s from https://developer.nutiteq.com/guides/packages
//
            // Decide what to download offline
            var    toBeDownloaded    = downloadArea;
            string importPackagePath = AssetUtils.CalculateResourcePath("world_ntvt_0_4.mbtiles");
            //	MapSetup.InitializePackageManager (packagesDir, importPackagePath, Map, toBeDownloaded);

            /// Online vector base layer
            var baseLayer = new NutiteqOnlineVectorTileLayer("nutibright-v2a.zip");

            /// Set online base layer
            Map.Layers.Add(baseLayer);

            MapSetup.AddMapOverlays(Map);

            var json = System.IO.File.ReadAllText(AssetUtils.CalculateResourcePath("capitals_3857.geojson"));


            //	MapSetup.addJosnLayer (Map, json);
        }