private async void Initialize() { // Get the offline tile package and use it as a basemap. string basemapPath = DataManager.GetDataFolder("1330ab96ac9c40a49e59650557f2cd63", "streetmap_SD.tpk"); ArcGISTiledLayer tiledBasemapLayer = new ArcGISTiledLayer(new TileCache(basemapPath)); // Create new Map with basemap. Map myMap = new Map(new Basemap(tiledBasemapLayer)); // Provide Map to the MapView. _myMapView.Map = myMap; // Add a graphics overlay for showing pins. _myMapView.GraphicsOverlays.Add(new GraphicsOverlay()); try { // Get the path to the locator. string locatorPath = DataManager.GetDataFolder("344e3b12368543ef84045ef9aa3c32ba", "san-diego-locator.loc"); // Load the geocoder. _geocoder = await LocatorTask.CreateAsync(new Uri(locatorPath)); // Enable controls now that the geocoder is ready. _addressSearchBar.UserInteractionEnabled = true; } catch (Exception e) { new UIAlertView("Error", e.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show(); } }
private async void Initialize() { // Create new Map with basemap Map myMap = new Map(Basemap.CreateStreets()); // Provide used Map to the MapView MyMapView.Map = myMap; // Subscribe to location changed events (to support zooming to current location) MyMapView.LocationDisplay.LocationChanged += LocationDisplay_LocationChanged; // Enable location display MyMapView.LocationDisplay.IsEnabled = true; // Enable tap-for-info pattern on results MyMapView.GeoViewTapped += MyMapView_GeoViewTapped; // Initialize the LocatorTask with the provided service Uri _geocoder = await LocatorTask.CreateAsync(_serviceUri); // Enable all controls now that the locator task is ready MySearchBox.IsEnabled = true; MyLocationBox.IsEnabled = true; MySearchButton.IsEnabled = true; MySearchRestrictedButton.IsEnabled = true; }
private async void Initialize() { if (await ApiKeyManager.CheckKeyValidity() != ApiKeyStatus.Valid) { await new MessageDialog2("Please use the settings dialog to configure an API Key.", "Error").ShowAsync(); return; } // Create new Map with basemap. Map myMap = new Map(Basemap.CreateImageryWithLabels()); // Enable tap-for-info pattern on results. MyMapView.GeoViewTapped += MyMapView_GeoViewTapped; // Assign the map to the MapView. MyMapView.Map = myMap; try { // Initialize the LocatorTask with the provided service Uri. _geocoder = await LocatorTask.CreateAsync(_serviceUri); // Enable UI controls now that the geocoder is ready. AutoSuggestBox.IsEnabled = true; AutoSuggestBox.IsSuggestionListOpen = true; } catch (Exception e) { await new MessageDialog2(e.ToString(), "Error").ShowAsync(); } }
private async void Initialize() { if (await ApiKeyManager.CheckKeyValidity() != ApiKeyStatus.Valid) { await new MessageDialog2("Please use the settings dialog to configure an API Key.", "Error").ShowAsync(); return; } // Create new Map with basemap. Map myMap = new Map(Basemap.CreateImageryWithLabels()); // Provide used Map to the MapView. MyMapView.Map = myMap; // Add a graphics overlay to the map for showing where the user tapped. MyMapView.GraphicsOverlays.Add(new GraphicsOverlay()); // Enable tap-for-info pattern on results. MyMapView.GeoViewTapped += MyMapView_GeoViewTapped; // Initialize the LocatorTask with the provided service Uri. try { _geocoder = await LocatorTask.CreateAsync(_serviceUri); } catch (Exception e) { await new MessageDialog2(e.ToString(), "Error configuring geocoder").ShowAsync(); } // Set the initial viewpoint. await MyMapView.SetViewpointCenterAsync(34.058, -117.195, 5e4); }
private async void MyMapView_Loaded(object sender, RoutedEventArgs e) { //住所検索用のジオコーディング タスクを初期化 onlineLocatorTask = await LocatorTask.CreateAsync(new Uri(WORLD_GEOCODE_SERVICE_URL)); //ArcGIS Online への参照を取得 ArcGISPortal arcGISOnline = await ArcGISPortal.CreateAsync(new Uri(PORTAL_URL)); // ID を基にアイテムを取得 var portalItem = await PortalItem.CreateAsync(arcGISOnline, "Web マップ ID"); //アイテムから Map オブジェクトを作成 var Map = new Map(portalItem); //MapView コントロールの Map プロパティに、Map を割り当て MyMapView.Map = Map; // グラフィックス オーバーレイが存在しない場合は、新規に追加 if (MyMapView.GraphicsOverlays.Count == 0) { geocodeResultGraphicsOverlay = new GraphicsOverlay() { Renderer = CreateGeocoordingSymbol(), }; MyMapView.GraphicsOverlays.Add(geocodeResultGraphicsOverlay); } isMapReady = true; }
private async void Initialize() {// Create new Map with basemap Map myMap = new Map(Basemap.CreateImageryWithLabels()); myMap.InitialViewpoint = new Viewpoint(34.05293, -118.24368, 6000); // Assign the map to the MapView MyMapView.Map = myMap; try { // Initialize the LocatorTask with the provided service Uri _geocoder = await LocatorTask.CreateAsync(_serviceUri); var vm = CoreDependencyService.GetViewModel <SearchViewModel>(); vm.MapView = MyMapView; // Enable the UI controls now that the LocatorTask is ready MySuggestButton.IsEnabled = true; MySearchBar.IsEnabled = true; } catch (Exception e) { await Application.Current.MainPage.DisplayAlert("Error", e.ToString(), "OK"); } }
private async void Initialize() { // Create new Map with basemap. Map myMap = new Map(Basemap.CreateImageryWithLabels()); // Enable tap-for-info pattern on results. MyMapView.GeoViewTapped += MyMapView_GeoViewTapped; // Assign the map to the MapView. MyMapView.Map = myMap; try { // Initialize the LocatorTask with the provided service Uri. _geocoder = await LocatorTask.CreateAsync(_serviceUri); // Enable UI controls now that the geocoder is ready. AutoSuggestBox.IsEnabled = true; AutoSuggestBox.IsSuggestionListOpen = true; } catch (Exception e) { await new MessageDialog(e.ToString(), "Error").ShowAsync(); } }
private async void Initialize() { // Create new Map with basemap Map myMap = new Map(Basemap.CreateStreets()); // Provide Map to the MapView _myMapView.Map = myMap; // Wire up the map view to support tapping on address markers _myMapView.GeoViewTapped += _myMapView_GeoViewTapped; // Subscribe to location events to zoom to current location _myMapView.LocationDisplay.LocationChanged += LocationDisplay_LocationChanged; // Enable location display _myMapView.LocationDisplay.IsEnabled = true; // Initialize the LocatorTask with the provided service Uri _geocoder = await LocatorTask.CreateAsync(_serviceUri); // Enable controls now that the geocoder is ready _mySearchBox.Enabled = true; _myLocationBox.Enabled = true; _mySearchButton.Enabled = true; _mySearchRestrictedButton.Enabled = true; }
private async void Initialize() { // Create new Map with basemap. Map myMap = new Map(Basemap.CreateImageryWithLabels()); // Provide used Map to the MapView. MyMapView.Map = myMap; // Add a graphics overlay to the map for showing where the user tapped. MyMapView.GraphicsOverlays.Add(new GraphicsOverlay()); // Enable tap-for-info pattern on results. MyMapView.GeoViewTapped += MyMapView_GeoViewTapped; // Initialize the LocatorTask with the provided service Uri. try { _geocoder = await LocatorTask.CreateAsync(_serviceUri); } catch (Exception e) { await Application.Current.MainPage.DisplayAlert("Error", e.ToString(), "OK"); } // Set the initial viewpoint. await MyMapView.SetViewpointCenterAsync(34.058, -117.195, 5e4); }
private async void Initialize() { // Create new Map with basemap. Map myMap = new Map(Basemap.CreateImageryWithLabels()); // Provide used Map to the MapView. _myMapView.Map = myMap; // Add a graphics overlay to the map for showing where the user tapped. _myMapView.GraphicsOverlays.Add(new GraphicsOverlay()); // Enable tap-for-info pattern on results. _myMapView.GeoViewTapped += _myMapView_GeoViewTapped; // Initialize the LocatorTask with the provided service Uri. try { _geocoder = await LocatorTask.CreateAsync(_serviceUri); } catch (Exception e) { new AlertDialog.Builder(this).SetMessage(e.ToString()).SetTitle("Error").Show(); } // Set the initial viewpoint. await _myMapView.SetViewpointCenterAsync(34.058, -117.195, 5e4); }
//Thread safe initialization of the geocoder private static async Task InitGeocoderAsync() { lock (LockInstance) { if (locator != null) { return; } if (initializeTask == null) { string path = System.IO.Path.Combine(MapViewModel.GetDataFolder(), "Geocoder", "CampusRooms.loc"); var task = LocatorTask.CreateAsync(new Uri(path, UriKind.RelativeOrAbsolute)); //Using relative path makes the create never complete. initializeTask = task.ContinueWith(t => { if (t.IsFaulted) { throw t.Exception; } lock (LockInstance) locator = t.Result; }); } } await initializeTask.ConfigureAwait(false); }
private async void Initialize() { if (await ApiKeyManager.CheckKeyValidity() != ApiKeyStatus.Valid) { await new MessageDialog2("Please use the settings dialog to configure an API Key.", "Error").ShowAsync(); return; } // Add event handler for when this sample is unloaded. Unloaded += SampleUnloaded; // Create new Map with basemap Map myMap = new Map(Basemap.CreateStreets()); // Subscribe to location changed event so that map can zoom to location MyMapView.LocationDisplay.LocationChanged += LocationDisplay_LocationChanged; // Enable location display MyMapView.LocationDisplay.IsEnabled = true; // Enable tap-for-info pattern on results MyMapView.GeoViewTapped += MyMapView_GeoViewTapped; // Assign the map to the MapView MyMapView.Map = myMap; // Initialize the LocatorTask with the provided service Uri _geocoder = await LocatorTask.CreateAsync(_serviceUri); // Enable all controls now that the locator task is ready SearchEntry.IsEnabled = true; LocationEntry.IsEnabled = true; SearchButton.IsEnabled = true; SearchViewButton.IsEnabled = true; }
private async void Initialize() { // Show a new map with streets basemap. _myMapView.Map = new Map(Basemap.CreateStreets()); // Initialize the geocoder with the provided service URL _geocoder = await LocatorTask.CreateAsync(_serviceUri); // Subscribe to location changed event so that map can zoom to location. _myMapView.LocationDisplay.LocationChanged += LocationDisplay_LocationChanged; // Enable location display on the map. _myMapView.LocationDisplay.IsEnabled = true; // Enable controls now that the geocoder is ready. _locationBox.Enabled = true; _searchBox.Enabled = true; _searchButton.Enabled = true; _searchInViewButton.Enabled = true; // Enable tap-for-info pattern on results. _myMapView.GeoViewTapped += MapView_GeoViewTapped; // Listen for taps on the search buttons. _searchButton.TouchUpInside += SearchButton_Touched; _searchInViewButton.TouchUpInside += SearchRestrictedButton_Touched; // Listen for text-changed events. _searchBox.AllEditingEvents += SearchBox_TextChanged; _locationBox.AllEditingEvents += LocationBox_TextChanged; }
private async void Initialize() { // Create new Map with basemap. Map myMap = new Map(BasemapStyle.ArcGISImagery); // Provide used Map to the MapView. MyMapView.Map = myMap; // Add a graphics overlay to the map for showing where the user tapped. MyMapView.GraphicsOverlays.Add(new GraphicsOverlay()); // Enable tap-for-info pattern on results. MyMapView.GeoViewTapped += MyMapView_GeoViewTapped; // Initialize the LocatorTask with the provided service Uri. try { _geocoder = await LocatorTask.CreateAsync(_serviceUri); } catch (Exception e) { await new MessageDialog(e.ToString(), "Error configuring geocoder").ShowAsync(); } // Set the initial viewpoint. await MyMapView.SetViewpointCenterAsync(34.058, -117.195, 5e4); }
private async void Initialize() { // Add event handler for when this sample is unloaded. Unloaded += SampleUnloaded; // Show a map with a streets basemap. MyMapView.Map = new Map(Basemap.CreateStreetsVector()); // Subscribe to location changed events (to support zooming to current location). MyMapView.LocationDisplay.LocationChanged += LocationDisplay_LocationChanged; // Enable location display. MyMapView.LocationDisplay.IsEnabled = true; // Enable tap-for-info pattern on results. MyMapView.GeoViewTapped += MyMapView_GeoViewTapped; // Initialize the LocatorTask with the provided service Uri. _geocoder = await LocatorTask.CreateAsync(_serviceUri); // Enable all controls now that the locator task is ready. MySearchBox.IsEnabled = true; MyLocationBox.IsEnabled = true; MySearchButton.IsEnabled = true; MySearchRestrictedButton.IsEnabled = true; }
private async void Initialize() { Map myMap = new Map(Basemap.CreateStreets()); Envelope initialLocation = new Envelope( 136.6, 35.72, 139.65, 35.68, SpatialReferences.Wgs84); myMap.InitialViewpoint = new Viewpoint(initialLocation); MyMapView.Map = myMap; //住所検索用のジオコーディング タスクを初期化 onlineLocatorTask = await LocatorTask.CreateAsync(new Uri(WORLD_GEOCODE_SERVICE_URL)); // グラフィックス オーバーレイの新規追加 geocodeResultGraphicsOverlay = new GraphicsOverlay() { Renderer = createGeocoordingSymbol(), }; MyMapView.GraphicsOverlays.Add(geocodeResultGraphicsOverlay); isMapReady = true; }
private async void Initialize() { // Create new Map with basemap Map myMap = new Map(Basemap.CreateStreets()); // Subscribe to location changed event so that map can zoom to location MyMapView.LocationDisplay.LocationChanged += LocationDisplay_LocationChanged; // Enable location display MyMapView.LocationDisplay.IsEnabled = true; // Enable tap-for-info pattern on results MyMapView.GeoViewTapped += MyMapView_GeoViewTapped; // Assign the map to the MapView MyMapView.Map = myMap; // Initialize the LocatorTask with the provided service Uri _geocoder = await LocatorTask.CreateAsync(_serviceUri); // Enable all controls now that the locator task is ready SearchEntry.IsEnabled = true; LocationEntry.IsEnabled = true; SearchButton.IsEnabled = true; SearchViewButton.IsEnabled = true; }
private async void Initialize() { // Get a new instance of the Imagery with Labels basemap Basemap _basemap = Basemap.CreateStreets(); // Create a new Map with the basemap Map myMap = new Map(_basemap); // Populate the MapView with the Map _myMapView.Map = myMap; // Initialize the geocoder with the provided service Uri _geocoder = await LocatorTask.CreateAsync(_serviceUri); // Subscribe to location changed event so that map can zoom to location _myMapView.LocationDisplay.LocationChanged += LocationDisplay_LocationChanged; // Enable location display on the map _myMapView.LocationDisplay.IsEnabled = true; // Enable controls now that the geocoder is ready _myLocationBox.Enabled = true; _mySearchBox.Enabled = true; _mySearchButton.Enabled = true; _mySearchRestrictedButton.Enabled = true; }
private async void Initialize() { // Create new Map with basemap Map myMap = new Map(Basemap.CreateImageryWithLabels()); // Provide used Map to the MapView MyMapView.Map = myMap; // Set addresses as items source SearchBox.ItemsSource = _addresses; // Enable tap-for-info pattern on results MyMapView.GeoViewTapped += MyMapView_GeoViewTapped; // Initialize the LocatorTask with the provided service Uri try { _geocoder = await LocatorTask.CreateAsync(_serviceUri); // Enable UI controls now that the LocatorTask is ready SearchBox.IsEnabled = true; SearchButton.IsEnabled = true; } catch (Exception e) { MessageBox.Show(e.ToString(), "Error"); } }
private async void Initialize() { // Create new Map with basemap Map myMap = new Map(Basemap.CreateImagery()); // Provide Map to the MapView _myMapView.Map = myMap; // Wire up the map view to support tapping on address markers _myMapView.GeoViewTapped += _myMapView_GeoViewTapped; try { // Initialize the LocatorTask with the provided service Uri _geocoder = await LocatorTask.CreateAsync(_serviceUri); // Enable interaction now that the geocoder is ready _suggestButton.Enabled = true; _addressSearchBar.Enabled = true; _searchButton.Enabled = true; } catch (Exception ex) { new AlertDialog.Builder(this).SetMessage(ex.ToString()).SetTitle("Error").Show(); } }
/// <summary> /// Returns the location of the specified address. /// </summary> /// <param name="address"></param> /// <param name="cancellationToken"></param> /// <returns></returns> public async Task <MapPoint> GeocodeAsync(string address) { var locator = await LocatorTask.CreateAsync(s_locatorService); var result = await locator.GeocodeAsync(address).ConfigureAwait(false); return(result?.FirstOrDefault()?.RouteLocation); }
private async void Initialize() { // Show a labeled imagery basemap. _myMapView.Map = new Map(Basemap.CreateImageryWithLabels()); // Initialize the geocoder with the provided service URL. _geocoder = await LocatorTask.CreateAsync(_serviceUri); // Enable controls now that the geocoder is ready. _addressSearchBar.UserInteractionEnabled = true; }
public async Task <MapPoint> Geocode(string address, CancellationToken cancellationToken) { LocatorTask locator = await LocatorTask.CreateAsync(new Uri(locatorService)); var result = await locator.GeocodeAsync(address).ConfigureAwait(false); if (result != null && result.Count > 0) { return(result.First().RouteLocation as MapPoint); } return(null); }
/// <summary> /// Intialize view model /// </summary> private async void Initialize() { try { // Load locator Locator = await LocatorTask.CreateAsync(new Uri(Configuration.GeocodeUrl)); } catch (Exception ex) { ErrorMessage = "Unable to load Geocoder. Searching may be affected."; StackTrace = ex.ToString(); } }
private async void Initialize() { // Web マップの URL を指定してマップを作成 var webMap = await Map.LoadFromUriAsync(new Uri("https://arcgis.com/home/item.html?id=9a6a1c9f857a4a68a6e405bb5917e620")); // マップビューのマップに設定 MyMapView.Map = webMap; //住所検索用のジオコーディング タスクを初期化 onlineLocatorTask = await LocatorTask.CreateAsync(new Uri(WORLD_GEOCODE_SERVICE_URL)); // グラフィックス オーバーレイの新規追加 geocodeResultGraphicsOverlay = new GraphicsOverlay() { Renderer = createGeocoordingSymbol(), }; MyMapView.GraphicsOverlays.Add(geocodeResultGraphicsOverlay); isMapReady = true; // マップがロードされた際の処理 if (MyMapView.Map.LoadStatus == LoadStatus.Loaded) { // マップビューのタップ イベントを登録 MyMapView.GeoViewTapped += OnMapViewTapped; // Web マップに含まれる最上位のレイヤーを取得 myFeatureLayer = (FeatureLayer)MyMapView.Map.OperationalLayers[1]; // フィーチャ レイヤからフィーチャ テーブルを定義 myFeatureTable = (ServiceFeatureTable)myFeatureLayer.FeatureTable; // リクエスト モードの設定 myFeatureTable.FeatureRequestMode = FeatureRequestMode.ManualCache; // フィーチャの検索用のパラメーターを作成 var queryParams = new QueryParameters(); // すべてのフィーチャを取得するように条件を設定 queryParams.WhereClause = "1=1"; // 検索結果にフィーチャのすべての属性情報(outFields の配列に "*" を指定)を含める var outputFields = new string[] { "*" }; // クエリの条件に基づいてフィーチャ テーブルにデータを設定する await myFeatureTable.PopulateFromServiceAsync(queryParams, true, outputFields); // マップビューにグラフィック表示用のオーバレイを追加 MyMapView.GraphicsOverlays.Add(myGraphicsOverlay); } }
private async void Initialize() { // Create new Map with basemap Map myMap = new Map(Basemap.CreateImageryWithLabels()); // Assign the map to the MapView MyMapView.Map = myMap; // Initialize the LocatorTask with the provided service Uri _geocoder = await LocatorTask.CreateAsync(_serviceUri); // Enable the UI controls now that the LocatorTask is ready MySuggestButton.IsEnabled = true; MySearchBar.IsEnabled = true; }
private async void Initialize() { // Create new Map with basemap Map myMap = new Map(Basemap.CreateStreets()); Envelope initialLocation = new Envelope( 136.6, 35.72, 139.65, 35.68, SpatialReferences.Wgs84); myMap.InitialViewpoint = new Viewpoint(initialLocation); // Assign the map to the MapView MyMapView.Map = myMap; // Initialize the LocatorTask with the provided service Uri _geocoder = await LocatorTask.CreateAsync(_serviceUri); }
public SearchViewModel() { _map.InitialViewpoint = new Viewpoint(34.05293, -118.24368, 6000); AddressSearchCommand = new CoreCommand(async(obj) => { // Initialize the LocatorTask with the provided service Uri _geocoder = await LocatorTask.CreateAsync(_serviceUri); await UpdateSearch(); }); StartGeolocation = new CoreCommand(async(obj) => { // Initialize the LocatorTask with the provided service Uri _geocoder = await LocatorTask.CreateAsync(_serviceUri); await UpdateCurrentLocation(); }); }
private async void Initialize() { // Get a new instance of the Imagery with Labels basemap Basemap _basemap = Basemap.CreateImageryWithLabels(); // Create a new Map with the basemap Map myMap = new Map(_basemap); // Populate the MapView with the Map _myMapView.Map = myMap; // Initialize the geocoder with the provided service Uri _geocoder = await LocatorTask.CreateAsync(_serviceUri); // Enable controls now that the geocoder is ready _addressSearchBar.UserInteractionEnabled = true; }
/// <summary> /// Get the address for the new tree by running a reverse geocode operation /// </summary> internal static async Task <string> GetAddressForAddedFeature(MapPoint newTreePoint) { // if the webmap used in the app is not the tree dataset map, this method will not work if (WebmapURL != TreeDatasetWebmapUrl) { return(null); } try { LocatorTask locator; // try using the online geocoder // if that fails, use the sideloaded offline locator try { locator = await LocatorTask.CreateAsync(new Uri(GeocodeUrl)); } catch { locator = await LocatorTask.CreateAsync( new Uri(Path.Combine(Directory.GetParent(Assembly.GetExecutingAssembly().Location).ToString(), OfflineLocatorPath))); } // call reverse geocoder var matches = await locator.ReverseGeocodeAsync(newTreePoint, new ReverseGeocodeParameters() { IsForStorage = true }); // in online mode only get the address as that is what the table already has in it // in offline mode, only the full address is avaialble, so get that if (matches.First().Attributes.ContainsKey("Address")) { return(matches.First().Attributes["Address"].ToString().ToUpper()); } else { return(matches.First().Attributes["Match_addr"].ToString().ToUpper()); } } catch { } // if unable to get address just don't populate it return(null); }