This Sample demonstrates how you can use ThinkGeo Cloud Client to get a geographic location into meaningful addresses from ThinkGeo GIS Server. It ships with an optimized set of worldwide coverage of cities and towns, but any customized data can be supported as well. ThinkGeo Cloud Client support would work in all of the Map Suite controls such …
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
ThinkGeoCloudReverseGeocoding
.gitignore
README.md
Screenshot.gif
Screenshot.png Added Screenshot.png. Feb 21, 2019
ThinkGeoCloudReverseGeocoding.sln

README.md

ThinkGeo Cloud Reverse Geocoding Sample for Wpf

Description

This Sample demonstrates how you can use ThinkGeo Cloud Client to get meaningful addresses from ThinkGeo GIS Server by a geographic location. It ships with an optimized set of worldwide coverage of cities and towns, but any customized data can be supported as well.

ThinkGeo Cloud Client support would work in all of the Map Suite controls such as Wpf, Web, MVC, WebApi, Android and iOS.

Please refer to Wiki for the details.

Screenshot

Requirements

This sample makes use of the following NuGet Packages

MapSuite 10.0.0

About the Code

Search the specific point and return best-matching places with nearbys

ReverseGeocodingClient reverseGeocodingClient = new ReverseGeocodingClient(clientId, clientSecret);
reverseGeocodingClient.BaseUris.Add(new Uri(GisServerUri));
ReverseGeocodingResult searchResult = await reverseGeocodingClient.SearchPointAsync(searchPoint.X, searchPoint.Y, 3857, searchRadius, DistanceUnit.Meter, reverseGeocodingOption);

Display the searched results on map

private void DisplaySearchResult(ReverseGeocodingResult searchResult)
{
    Collection<ReverseGeocodingLocation> serachedAddresses = new Collection<ReverseGeocodingLocation>();
    Collection<ReverseGeocodingLocation> serachedIntersection = new Collection<ReverseGeocodingLocation>();
    if (searchResult?.BestMatchLocation != null)
    {
        // Display address of the BestMatchingPlace in the left panel and add a marker.
        txtBestMatchingPlace.Text = searchResult.BestMatchLocation.Address;
        Marker marker = CreateMarkerByCategory("BestMatchingPlace", searchPoint, searchResult.BestMatchLocation.Address);
        var bestmatchingMarkerOverlay = (SimpleMarkerOverlay)WpfMap.Overlays["BestMatchingMarkerOverlay"];
        bestmatchingMarkerOverlay.Markers.Add(marker);

        var nearbyLocations = new List<ReverseGeocodingLocation>(searchResult.NearbyLocations);
        int intersectionIndex = 0;
        var intersections = nearbyLocations.FindAll(p => p.LocationCategory.ToLower().Contains("intersection"));
        foreach (var intersection in intersections)
        {
            serachedIntersection.Add(intersection);
            AddPropertiesForPlace(intersection, intersectionIndex);
            intersectionIndex++;
            nearbyLocations.Remove(intersection);
        }
        int addressIndex = 0;
        var addressPoints = nearbyLocations.FindAll(p => p.LocationCategory.ToLower().Contains("addresspoint"));
        foreach (var address in addressPoints)
        {
            serachedAddresses.Add(address);
            AddPropertiesForPlace(address, addressIndex);
            addressIndex++;
            nearbyLocations.Remove(address);
        }

        int placeIndex = 0;
        foreach (var place in nearbyLocations)
        {
            if (!nameof(LocationCategories.Aeroway).Equals(place.LocationCategory, StringComparison.InvariantCultureIgnoreCase)
                && !nameof(LocationCategories.Road).Equals(place.LocationCategory, StringComparison.InvariantCultureIgnoreCase)
                && !nameof(LocationCategories.Rail).Equals(place.LocationCategory, StringComparison.InvariantCultureIgnoreCase)
                && !nameof(LocationCategories.Waterway).Equals(place.LocationCategory, StringComparison.InvariantCultureIgnoreCase))
            {
                serachedPlaces.Add(place);
                AddPropertiesForPlace(place, placeIndex);
                placeIndex++;
            }
        }
        // Bind addresses,intersections,places to listbox.
        lsbAddress.ItemsSource = serachedAddresses;
        lsbPlaces.ItemsSource = serachedPlaces;
        lsbIntersection.ItemsSource = serachedIntersection;
    }
}

Getting Help

Map Suite Desktop for Wpf Wiki Resources

Map Suite Desktop for Wpf Product Description

ThinkGeo Community Site

ThinkGeo Web Site

Key APIs

This example makes use of the following APIs:

Working...

About Map Suite

Map Suite is a set of powerful development components and services for the .Net Framework.

About ThinkGeo

ThinkGeo is a GIS (Geographic Information Systems) company founded in 2004 and located in Frisco, TX. Our clients are in more than 40 industries including agriculture, energy, transportation, government, engineering, software development, and defense.