none
V8 Web control AutosuggestManager Country filter RRS feed

  • Question

  • I want to fetch addresses of US country only, Currently it is fetching addresses from whole world

    How could it possible with bing AutoSuggest module

    Here below is my source
    -----------------------------
    $.loadScript('http://www.bing.com/api/maps/mapcontrol?callback=GetMap', function(){
        });

    function GetMap() {
            Microsoft.Maps.loadModule('Microsoft.Maps.AutoSuggest', {
                callback: function () {
                    var manager = new Microsoft.Maps.AutosuggestManager({
                        maxResults: 5,
                    });
                    manager.attachAutosuggest('#searchBox', '#searchBoxContainer', selectedSuggestion);
                },
                errorCallback: function(msg){
                    alert(msg);
                },
                credentials: 'key' 
            });
        }

    Wednesday, June 21, 2017 4:26 PM

Answers

  • There is a new AutosuggestOption called countryCode which takes in a 2-character country ISO code which will limit the suggestions to that country. Here is an example that limits the results to the US:

        var options = {
            maxResults: 4,
            map: map,
            countryCode: 'US'
        };
        var manager = new Microsoft.Maps.AutosuggestManager(options);
    This only works with the experimental branch at the moment. To access the experimental branch add the following to the map script URL: &branch=experimental


    [Blog] [twitter] [LinkedIn]

    Saturday, September 30, 2017 4:24 PM

All replies

  • Currently there is no option to limit the auto suggest module to a single country. This is however on the feature request list.

    [Blog] [twitter] [LinkedIn]

    Thursday, June 22, 2017 4:06 AM
  • Ok! Thank you
    Thursday, June 22, 2017 7:47 AM
  • Do we have any idea when this option going to implement in V8 control AutosuggestManager

    We need it soon as possible :(
    Tuesday, September 26, 2017 2:20 PM
  • This is already implemented in the experimental branch and will be in the main release branch in a couple of weeks.

    [Blog] [twitter] [LinkedIn]

    Tuesday, September 26, 2017 10:33 PM
  • Is great to hear that we are getting this feature imminently. How do I use it on the experimental branch presently? I'm new to Bing Maps and have been digging around the examples and docs and haven't been able to track it down. Appreciate it's new so I guess that's why it's not documented as yet but wondered if you could point me in the right direction?

    Thanks!

    Friday, September 29, 2017 12:08 PM
  • There is a new AutosuggestOption called countryCode which takes in a 2-character country ISO code which will limit the suggestions to that country. Here is an example that limits the results to the US:

        var options = {
            maxResults: 4,
            map: map,
            countryCode: 'US'
        };
        var manager = new Microsoft.Maps.AutosuggestManager(options);
    This only works with the experimental branch at the moment. To access the experimental branch add the following to the map script URL: &branch=experimental


    [Blog] [twitter] [LinkedIn]

    Saturday, September 30, 2017 4:24 PM
  • First of all, thank you Ricky_Brundritt for quick reply 

    We will wait till deploy this on main branch, if possible please inform here once it go to main branch 

    Thanks once again :)
    Tuesday, October 3, 2017 3:39 PM
  • I believe this should be in the main release branch next week.

    [Blog] [twitter] [LinkedIn]

    Tuesday, October 3, 2017 7:57 PM
  • It works like a charm. Big thanks for this feature!

    Thursday, November 2, 2017 1:11 PM