Bing Maps API Issue with Retrieving Boundaries

Balasaheb Molawade 136 Reputation points
2024-08-29T14:11:00.2833333+00:00

Hi,

We are currently utilizing the Bing Maps API (https://www.bing.com/api/maps/sdk/mapcontrol/isdk/sdsloadmultipleboundaries#JS) to obtain the boundaries for postal code areas in England. However, we have encountered an issue where the API returns incorrect boundaries. Specifically, we are receiving the same boundary for different postal code areas, such as CO, CB, CM and EN. We are using the entityType: 'postalcode4' in request which corresponds to postal code areas.

We are receiving the following boundary for CM from Bing map API.

1

However, the correct boundary should be as follows:

2

Has anyone else experienced this issue? If so, could you please share any resolutions or workarounds that you may have implemented?

Your assistance in resolving this matter would be greatly appreciated.

Thank you for your time and support.

Thanks!

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

1 answer

Sort by: Most helpful
  1. rbrundritt 18,591 Reputation points Microsoft Employee
    2024-08-29T15:53:23.5766667+00:00

    If you are looking for things like "CM22" try "Postcode3" and "Postcode4" would be all of "CM".

    Now, if you are looking for things like "CM22", these are known as postal "districts" in the UK. This data is actually available as open data in the UK. If you need to visualize a lot of this regularly, it would be much more efficient and cheaper to self-host a copy of that data. Here is a good link where someone has converted the data into GeoJSON (and KML if you prefer): https://github.com/missinglink/uk-postcode-polygons/tree/master

    Now if the above doesn't work, here is some good background to understand how the Bing Maps service works. The way the Bing Maps boundary service works is that it retrieves the specified boundary type that intersects a specified coordinate. This is the cause of nearly all issues I've seen reported with this service. If you provide a text input, like the name of a postal code, it gets geocoded and the coordinate of the first result is used to do the intersection test. Unfortunately, the geocoder implementation used by the boundary service doesn't expose all the geocoding service options to fine tune your request. As such, it is better to geocode your data ahead of time to ensure you have the right results/coordinates, then use those coordinates to retrieve the boundaries.

    Azure Maps has two boundary services. The latest one is basically the same as the Bing Maps one but with a different API interface and a response format that uses an open data format (GeoJson). The older boundary service in Azure Maps (v1) I actually prefer as you retrieve boundaries by providing unique IDs, and there is a batch service to get those boundaries. However, to get those unique IDs you have to first geocode your data (v1 search service) and the geocode service will return the unique ID for each result. So this is basically the same thing as I suggested in the first paragraph.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.