Bing Maps Web Control - Am I using the wrong GetBoundaryRequestOptions entityType to draw a border around a county?

Helene Vu 20 Reputation points
2024-04-01T18:25:02.9933333+00:00

I'm using the Bing Maps v8 web control and using the Spatial Data Service Module to draw boundaries around specified cities, counties, and states. I tried testing out drawing a boundary around Clark, NV with the entity type AdminDivision2 and it's drawing the boundary around the city Clark, NV instead of the county. Am I doing something wrong? Or is this a bug? I've also tried drawing a boundary around Orange, CA with the entity type AdminDivision2 and it correctly drew the boundary around the county and not the city.

Azure Maps
Azure Maps
An Azure service that provides geospatial APIs to add maps, spatial analytics, and mobility solutions to apps.
592 questions
0 comments No comments
{count} votes

Accepted answer
  1. rbrundritt 15,311 Reputation points Microsoft Employee
    2024-04-01T22:43:15.17+00:00

    If you are following this sample: https://samples.bingmapsportal.com/?sample=geodata-search-boundary it does the following:

    1. Geocodes the input query.
    2. Takes the first result and uses it's coordinates to find the intersecting boundary using the Geodata API.

    Doing a quick test, geocoding "Clark, NV" returns two results. The first has an entityType of PopulatedPlace (the city), and the second is AdminDivision2 (the county).

    If you are only using the GeoData API and passing in "Clark, NV" as the "address query", it will do the same thing as above and use the coordinate of the first result as the center point of the search. If you specify that you want an AdminDivision2, it will match with the county that intersects the first result of the geocode (the county the city of Clark, NV is in), in this case Storey County, NV. Not that in the documentation for this API, when using this API with a string input, that input is expected to be an address. If you pass in a higher-level entity such as city or county, you are likely to get a mismatch. The idea here is you pass in an address and can get all the boundaries within the hierarchy of that address (city, zip code, county, state, country).

    There are two ways to resolve this issue:

    1. Geocode the query first and pick the most suitable result. In this case the AdminDivision2 is the second geocode result when "Clark, NV" is passed in. So, you can check the entity type and choose the one that you prefer. You can then use the coordinates from the preferred result with the GeoData API.
    2. Alternatively, as IoTGirl mentioned, when it comes to US countries, adding the word "county" to the query causes the geocoder to exclude the city result. For example: "Clark county, NV".

    I also tested "Clark, NV" in Azure Maps here: https://samples.azuremaps.com/?search=boundary&sample=search-for-boundaries and the county result was found as the first result (city boundary wasn't returned. Not sure if that's a gap, might be due to such low population in that city/town).

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. IoTGirl 2,976 Reputation points Microsoft Employee
    2024-04-01T20:41:22.1633333+00:00

    Hi Helene,

    Can you please clarify what call you are making? If I do https://www.bing.com/api/maps/sdkrelease/mapcontrol/isdk/sdsloadboundaryfromsearch and change the call to:

        var geocodeRequest = {
            where: 'Clark County, NV',
    

    I think I get what you want. Can you confirm?

    Sincerely, IoTGirl