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() { 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 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); }
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() { 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; }
public ReverseGeocode() { InitializeComponent(); MyMapView.Map.InitialViewpoint = new Viewpoint(new Envelope(-74.2311, 4.47791, -73.964, 4.8648, SpatialReference.Create(4326))); _graphicsOverlay = MyMapView.GraphicsOverlays[0]; _locator = new OnlineLocatorTask(new Uri(OnlineLocatorUrl)); }
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; }
public BatchGeocoding() { this.InitializeComponent(); mapView1.Map.InitialViewpoint = new Viewpoint(new Envelope(-15000000, 2000000, -7000000, 8000000, SpatialReferences.WebMercator)); _locatorTask = new OnlineLocatorTask (new Uri("http://serverapps101.esri.com/arcgis/rest/services/USA_Geocode/GeocodeServer", UriKind.Absolute), ""); geocodedResults = mapView1.Map.Layers["LocationGraphicsLayer"] as GraphicsLayer; //List of addresses to geocode batchaddresses.Add(new Dictionary <string, string> { { "Street", "4409 Redwood Dr" }, { "Zip", "92501" } }); batchaddresses.Add(new Dictionary <string, string> { { "Street", "3758 Cedar St" }, { "Zip", "92501" } }); batchaddresses.Add(new Dictionary <string, string> { { "Street", "3486 Orange St" }, { "Zip", "92501" } }); batchaddresses.Add(new Dictionary <string, string> { { "Street", "2999 4th St" }, { "Zip", "92507" } }); batchaddresses.Add(new Dictionary <string, string> { { "Street", "3685 10th St" }, { "Zip", "92501" } }); AddressListbox.ItemsSource = batchaddresses; }
/// <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); }
/// <summary>Construct reverse geocode sample control</summary> public ReverseGeocode() { InitializeComponent(); Envelope extent = new Envelope(-117.387, 33.97, -117.355, 33.988, SpatialReferences.Wgs84); mapView.Map.InitialExtent = GeometryEngine.Project(extent, SpatialReferences.WebMercator) as Envelope; _locator = new OnlineLocatorTask(new Uri("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer")); }
public BatchGeocoding() { this.InitializeComponent(); mapView1.Map.InitialExtent = new Envelope(-15000000, 2000000, -7000000, 8000000) { SpatialReference = new SpatialReference(102100) }; _locatorTask = new OnlineLocatorTask (new Uri("http://serverapps101.esri.com/arcgis/rest/services/USA_Geocode/GeocodeServer", UriKind.Absolute), ""); geocodedResults = mapView1.Map.Layers["LocationGraphicsLayer"] as GraphicsLayer; //List of addresses to geocode batchaddresses.Add(new Dictionary<string, string> { { "Street", "4409 Redwood Dr" }, { "Zip", "92501" } }); batchaddresses.Add(new Dictionary<string, string> { { "Street", "3758 Cedar St" }, { "Zip", "92501" } }); batchaddresses.Add(new Dictionary<string, string> { { "Street", "3486 Orange St" }, { "Zip", "92501" } }); batchaddresses.Add(new Dictionary<string, string> { { "Street", "2999 4th St" }, { "Zip", "92507" } }); batchaddresses.Add(new Dictionary<string, string> { { "Street", "3685 10th St" }, { "Zip", "92501" } }); AddressListbox.ItemsSource = batchaddresses; }
/// <summary>Construct reverse geocode sample control</summary> public ReverseGeocode() { InitializeComponent(); _graphicsOverlay = MyMapView.GraphicsOverlays[0]; _locator = new OnlineLocatorTask(new Uri(OnlineLocatorUrl)); }
/// <summary>Construct reverse geocode sample control</summary> public ReverseGeocode() { InitializeComponent(); _locator = new OnlineLocatorTask(new Uri("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer")); }
/// <summary> /// Initializes layers and tasks /// </summary> protected override async Task InitializeAsync() { // Create map with layers and set startup location var map = new Map() { InitialExtent = new Envelope(-13636132.3698584, 4546349.82732426, -13633579.1021618, 4547513.1599185, SpatialReferences.WebMercator) }; Map = map; // Basemap layer from ArcGIS Online hosted service var basemap = new ArcGISTiledMapServiceLayer() { ID = "Basemap", DisplayName = "Basemap", ServiceUri = "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer" }; // Initialize layer in Try - Catch Exception exceptionToHandle = null; try { await basemap.InitializeAsync(); map.Layers.Add(basemap); // Create graphics layer for start and endpoints CreateEndpointLayer(); CreateRouteLayer(); // Create geocoding and routing tasks _locatorTask = new LocalLocatorTask(@"../../../../Data/Locators/SanFrancisco/SanFranciscoLocator.loc"); _routeTask = new LocalRouteTask(@"../../../../Data/Networks/RuntimeSanFrancisco.geodatabase", "Routing_ND"); IsInitialized = true; } catch (Exception exception) { // Exception is thrown ie if layer url is not found - ie. {"Error code '400' : 'Invalid URL'"} exceptionToHandle = exception; } if (exceptionToHandle != null) { // Initialization failed, show message and return await MessageService.Instance.ShowMessage(string.Format( "Could not create basemap. Error = {0}", exceptionToHandle.ToString()), "An error occured"); } }
private async Task SetupLocator() { if (!IsOnline) { _locatorTask = new LocalLocatorTask(@"..\..\..\..\..\samples-data\locators\san-diego\san-diego-locator.loc"); } else { _locatorTask = new OnlineLocatorTask(new Uri("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"), string.Empty); } }
private async void FindAddressButton_Click(object sender, RoutedEventArgs e) { _locatorTask = new OnlineLocatorTask (new Uri("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer", UriKind.Absolute), ""); Dictionary<string, string> address = new Dictionary<string, string>(); if (!string.IsNullOrEmpty(InputAddress.Text)) address.Add("Address", InputAddress.Text); if (!string.IsNullOrEmpty(City.Text)) address.Add("City", City.Text); if (!string.IsNullOrEmpty(State.Text)) address.Add("Region", State.Text); if (!string.IsNullOrEmpty(Zip.Text)) address.Add("Postal", Zip.Text); var candidateFields = new List<string> {"Address", "City","Region", "Postal" }; try { var results = await _locatorTask.GeocodeAsync(address, candidateFields, new CancellationTokenSource().Token); if (_candidateGraphicsLayer.Graphics != null && _candidateGraphicsLayer.Graphics.Count > 0) _candidateGraphicsLayer.Graphics.Clear(); if (results != null) { if (results.Count == 0) await new MessageDialog("Cannot find this address").ShowAsync(); else { foreach (var candidate in results) { if (candidate.Score >= 80) { Graphic graphic = new Graphic() { Geometry = candidate.Location }; graphic.Attributes.Add("Address", candidate.Address); string latlon = String.Format("{0}, {1}", candidate.Location.X, candidate.Location.Y); graphic.Attributes.Add("LatLon", latlon); if (candidate.Location.SpatialReference == null) { candidate.Location.SpatialReference = SpatialReferences.Wgs84; } _candidateGraphicsLayer.Graphics.Add(graphic); } } //ZoomToExtent(); } } } catch (Exception) { } }