Exemplo n.º 1
0
        protected override void OnCreate(Android.OS.Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "mainGPS" layout resource, reload MapView
            SetContentView(Resource.Layout.MainGPS);
            mapView = (MapView)FindViewById(Resource.Id.mapView);

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

            mapView.Layers.Add(baseLayer);

            // bind the textViewMessage
            _textViewMessage = FindViewById <TextView> (Resource.Id.textViewMessage);

            // create layer and add object to the layer, finally add layer to the map.
            // All overlay layers must be same projection as base layer, so we reuse it
            _markerDataSource = new LocalVectorDataSource(mapView.Options.BaseProjection);
            var _markerLayer = new VectorLayer(_markerDataSource);

            mapView.Layers.Add(_markerLayer);

            // inizialize the location manager to get the current position
            InitializeLocationManager();
        }
Exemplo n.º 2
0
        protected override void OnCreate(Android.OS.Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

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

            mapView.Layers.Add(baseLayer);
        }
        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);
        }
        protected override void OnCreate(Android.OS.Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

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

            mapView.Layers.Add(baseLayer);

            // read json from assets and add to map
            string json;

            using (System.IO.StreamReader sr = new System.IO.StreamReader(Assets.Open("capitals_3857.geojson")))
            {
                json = sr.ReadToEnd();
            }

            MapSetup.addJosnLayer(mapView, json);
        }
Exemplo n.º 5
0
        protected override void OnCreate(Android.OS.Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

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

            mapView.Layers.Add(baseLayer);


            // create PackageManager instance for dealing with offline packages
            var packageFolder = new File(GetExternalFilesDir(null), "routingpackages");

            if (!(packageFolder.Mkdirs() || packageFolder.IsDirectory))
            {
                Log.Fatal("Could not create package folder!");
            }

            packageManager = new NutiteqPackageManager(ROUTING_PACKAGEMANAGER_SOURCE, packageFolder.AbsolutePath);
            packageManager.PackageManagerListener = new RoutingPackageListener(this);
            packageManager.Start();

            // fetch list of available packages from server. Note that this is asynchronous operation and listener will be notified via onPackageListUpdated when this succeeds.
            packageManager.StartPackageListDownload();

            // create offline routing service connected to package manager
            offlineRoutingService = new PackageManagerRoutingService(packageManager);

            // create additional online routing service that will be used when offline package is not yet downloaded or offline routing fails
            onlineRoutingService = new NutiteqOnlineRoutingService(ROUTING_SERVICE_SOURCE);

            // define layer and datasource for route line and instructions
            routeDataSource = new LocalVectorDataSource(baseProjection);
            VectorLayer routeLayer = new VectorLayer(routeDataSource);

            mapView.Layers.Add(routeLayer);


            // define layer and datasource for route start and stop markers
            routeStartStopDataSource = new LocalVectorDataSource(baseProjection);
            // Initialize a vector layer with the previous data source
            VectorLayer vectorLayer = new VectorLayer(routeStartStopDataSource);

            // Add the previous vector layer to the map
            mapView.Layers.Add(vectorLayer);
            // Set visible zoom range for the vector layer
            vectorLayer.VisibleZoomRange = new MapRange(0, 22);


            // set route listener
            RouteMapEventListener mapListener = new RouteMapEventListener(this);

            mapView.MapEventListener = mapListener;

            // create markers for start & end, and a layer for them
            MarkerStyleBuilder markerStyleBuilder = new MarkerStyleBuilder();

            markerStyleBuilder.Bitmap = BitmapUtils
                                        .CreateBitmapFromAndroidBitmap(BitmapFactory.DecodeResource(
                                                                           Resources, Resource.Drawable.olmarker));
            markerStyleBuilder.HideIfOverlapped = false;
            markerStyleBuilder.Size             = 30;

            markerStyleBuilder.Color = new Nutiteq.Graphics.Color(Android.Graphics.Color.Green);

            startMarker         = new Marker(new MapPos(0, 0), markerStyleBuilder.BuildStyle());
            startMarker.Visible = false;


            markerStyleBuilder.Color = new Nutiteq.Graphics.Color(Android.Graphics.Color.Red);

            stopMarker         = new Marker(new MapPos(0, 0), markerStyleBuilder.BuildStyle());
            stopMarker.Visible = false;

            routeStartStopDataSource.Add(startMarker);
            routeStartStopDataSource.Add(stopMarker);

            markerStyleBuilder.Color  = new Nutiteq.Graphics.Color(Android.Graphics.Color.White);
            markerStyleBuilder.Bitmap = BitmapUtils
                                        .CreateBitmapFromAndroidBitmap(BitmapFactory.DecodeResource(
                                                                           Resources, Resource.Drawable.direction_up));
            instructionUp = markerStyleBuilder.BuildStyle();

            markerStyleBuilder.Bitmap = BitmapUtils
                                        .CreateBitmapFromAndroidBitmap(BitmapFactory.DecodeResource(
                                                                           Resources, Resource.Drawable.direction_upthenleft));
            instructionLeft = markerStyleBuilder.BuildStyle();

            markerStyleBuilder.Bitmap = BitmapUtils
                                        .CreateBitmapFromAndroidBitmap(BitmapFactory.DecodeResource(
                                                                           Resources, Resource.Drawable.direction_upthenright));

            instructionRight = markerStyleBuilder.BuildStyle();

            // style for instruction balloons
            balloonPopupStyleBuilder = new BalloonPopupStyleBuilder();
            balloonPopupStyleBuilder.TitleMargins = new BalloonPopupMargins(4, 4, 4, 4);

            // finally animate map to Estonia
            mapView.FocusPos = baseProjection.FromWgs84(new MapPos(25.662893, 58.919365));
            mapView.Zoom     = 7;

            Toast.MakeText(ApplicationContext, "Long-press on map to set route start and finish", ToastLength.Long).Show();
        }