Exemplo n.º 1
0
        private async void Initialize()
        {
            //Exercise 1: Create new Map with basemap and initial location
            myMap = new Map(Basemap.CreateNationalGeographic());
            //Exercise 1: Assign the map to the MapView
            mapView.Map = myMap;



            //Exercise 3: Add mobile map package to the map
            var mmpk = await MobileMapPackage.OpenAsync(MMPK_PATH);

            if (mmpk.Maps.Count >= 0)
            {
                myMap = mmpk.Maps[0];
                //Exercise 3: Mobile map package does not contain a basemap so must add one.
                myMap.Basemap = Basemap.CreateNationalGeographic();
                mapView.Map   = myMap;
            }
            mapView.GraphicsOverlays.Add(bufferAndQueryMapGraphics);
            mapView.GraphicsOverlays.Add(mapRouteGraphics);

            Uri             routeServiceUri = new Uri("http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World");
            TokenCredential credentials     = await AuthenticationManager.Current.GenerateCredentialAsync(routeServiceUri, "username", "password");

            routeTask = await RouteTask.CreateAsync(routeServiceUri, credentials);

            try
            {
                routeParameters = await routeTask.GenerateDefaultParametersAsync();
            }
            catch (Exception error)
            {
                Console.WriteLine(error.Message);
            }
        }