none
Bing Map Autosuggest manager issue with zip code. RRS feed

  • Question

  • Dear All,  I am using Bing map AutosuggestManager in my project , I am facing few issues in the autosuggestions when querying zip-code particularly for number of characters in zip code ,
    when i am searching for zip code 12345[Rotterdam, New York 12345, United States], while entering the zip code 12 or 123 no auto-suggestions are populated,but it is displayed on 4th character 1234

    But in case of Zip-code 10001 [New York, 10001, United States], we are getting auto-suggestion for 2 or 3 characters. Ex: 10 or 100,Kindly help.

    Below is the code -  

    <!DOCTYPE html>
    <html>
    <head>
        <title></title>
        <meta charset="utf-8" />
        <script type='text/javascript'
                src='http://www.bing.com/api/maps/mapcontrol?callback=GetMap' 
                async defer></script>
        <script type='text/javascript'>
        function GetMap() {
            Microsoft.Maps.loadModule('Microsoft.Maps.AutoSuggest', {
                callback: function () {
                    var manager = new Microsoft.Maps.AutosuggestManager({
                       
                        addressSuggestions:false,
                        countryCode:'US'
                    });
                    manager.attachAutosuggest('#searchBox', '#searchBoxContainer', selectedSuggestion);
                },
                errorCallback: function(msg){
                    alert(msg);
                },
                credentials: 'KEY' 
            });
        }
    
        function selectedSuggestion(result) {
            //Populate the address textbox values.
            document.getElementById('addressLineTbx').value = result.address.addressLine || '';
            document.getElementById('cityTbx').value = result.address.locality || '';
            document.getElementById('countyTbx').value = result.address.district || '';
            document.getElementById('stateTbx').value = result.address.adminDistrict || '';
            document.getElementById('postalCodeTbx').value = result.address.postalCode || '';
            document.getElementById('countryTbx').value = result.address.countryRegion || '';
        }
        </script>
        <style>
            #searchBox {
                width: 400px;
            }
            
            .addressForm {
                margin-top:10px;
                background-color: #008272;
                color: #fff;
                border-radius:10px;
                padding: 10px;
            }
    
            .addressForm input{
                width:265px;
            }
        </style>
    </head>
    <body>
        <div id='searchBoxContainer'>
            <input type='text' id='searchBox'/>
        </div>
    
        <table class="addressForm">
            <tr><td>Street Address:</td><td><input type="text" id="addressLineTbx"/></td></tr>
            <tr><td>City:</td><td><input type="text" id="cityTbx"/></td></tr>
            <tr><td>County:</td><td><input type="text" id="countyTbx"/></td></tr>
            <tr><td>State:</td><td><input type="text" id="stateTbx"/></td></tr>
            <tr><td>Zip Code:</td><td><input type="text" id="postalCodeTbx"/></td></tr>
            <tr><td>Country:</td><td><input type="text" id="countryTbx"/></td></tr>
        </table>
    </body>
    </html>
    
    Thanks.

    Friday, March 9, 2018 1:22 PM

Answers

  • Here is what the development team came back with:

    This is because we only search for most popular places when the prefix length is shorter than 4 characters for performance reason. So when user types ‘123’, there is no popular place that can match this postcode but while user types 100, the New York is matched because it’s very popular.


    [Blog] [twitter] [LinkedIn]

    Thursday, March 15, 2018 4:59 PM

All replies

  • Not sure on this one, haven't seen it before. I've sent this over to our autosuggest team to see if they have any insights, will report back.

    [Blog] [twitter] [LinkedIn]

    Friday, March 9, 2018 2:19 PM
  • Here is what the development team came back with:

    This is because we only search for most popular places when the prefix length is shorter than 4 characters for performance reason. So when user types ‘123’, there is no popular place that can match this postcode but while user types 100, the New York is matched because it’s very popular.


    [Blog] [twitter] [LinkedIn]

    Thursday, March 15, 2018 4:59 PM