none
Bing Map Api RRS feed

  • Question

  • Hello I was trying to use bing map api for address and postal code validation. I want to validate both as in the postal code entered is in the relevant to that address or not. I found the code on bing map website but it does not validates the postal code.

    function geocodeRequest()
    {
        createSearchManager();
        var where = 'Denver, CO';
        var userData = { name: 'Maps Test User', id: 'XYZ' };
        var request =
        {
            where: where,
            count: 5,
            bounds: map.getBounds(),
            callback: onGeocodeSuccess,
            errorCallback: onGeocodeFailed,
            userData: userData
        };
        searchManager.geocode(request);
    }
    function onGeocodeSuccess(result, userData)
    {
        if (result) {
            map.entities.clear();
            var topResult = result.results && result.results[0];
            if (topResult) {
                var pushpin = new Microsoft.Maps.Pushpin(topResult.location, null);
                map.setView({ center: topResult.location, zoom: 10 });
                map.entities.push(pushpin);
            }
        }
    }
    function onGeocodeFailed(result, userData) {
        displayAlert('Geocode failed');
    }

    if (searchManager)
    {
        geocodeRequest();
    }
    else
    {
        Microsoft.Maps.loadModule('Microsoft.Maps.Search', { callback: geocodeRequest });
    }

    If I use this and put a zip code from new York it stills points me to the Denver. Is there any way I can try to validate both. I tried few if and else statements but it is not working. Please suggest any ways to do it.

    Thanks

    Friday, June 23, 2017 2:06 PM

Answers