AntoOne
AntoOne

Reputation: 99

Bing reverse geocoding

I am using Bing map to get the postal code from a pin location. With this code, sometimes I am getting a full postal code (eg. G0L 4K0) and sometimes I receive a partial postal code (eg. G0L).

function reverseGeocode(pin) {
            var pinLocation = new Microsoft.Maps.Location(pin.geometry.y, pin.geometry.x);
            console.log(pinLocation);
            var searchRequest = {
                location: pinLocation,
                callback: function (r) {
                    console.log(r);
                    postalCodeStart = r;
                },
                errorCallback: function (e) {
                }
            };
            searchManager.reverseGeocode(searchRequest);
        }

by example, with this url : "http://dev.virtualearth.net/REST/v1/Locations/45.5124,-73.5547?o=json&key=myKey", I get "postalCode":"H2L"

I really need to receive the full postal code, how can I get it?

Thanks in advance

Upvotes: 1

Views: 1727

Answers (2)

Jason Hong
Jason Hong

Reputation: 1

Bing map API recent update now has the full postcode.

The URL seems working fine now: "http://dev.virtualearth.net/REST/v1/Locations/45.5124,-73.5547?o=json&key=myKey" is showing: H2L 2P1

Upvotes: 0

AntoOne
AntoOne

Reputation: 99

Finally I found that Bing map's api is not always perfect while using its reverse geocoding (i found many questions related to my issue on internet)

https://nominatim.openstreetmap.org/reverse.php?format=html seems to have a morre complete api while you need to use reverse geocoding

Upvotes: 0

Related Questions