none
Bing Maps Search Module ignoring LocationRect bounds parameter RRS feed

  • Question

  • When using the Bing Maps Search Module 'Microsoft.Maps.Search', I would like to restrict results to places within the UK. The documentation says that I can provide a LocationRect bounding box under the GeocodeRequestOptions. When I do this, the results are still popping in from all over the world. The following code illustrates the problem.

    var ukbb = Microsoft.Maps.LocationRect.fromCorners(new Microsoft.Maps.Location(60.854691, -9.06151), new Microsoft.Maps.Location(49.871159, 1.76896)); //UK Bounding Box
    var searchRequest = {
                    where: 'Bangor',
                    bounds: ukbb,
                    callback: function (r) { console.log(r.results); }
    };

    Checking the console output shows five places, of which only the first and third are relevant to me:

    - Bangor, Gwynedd
    - Bangor, ME
    - Bangor, North Down
    - Bangor, PA
    - Bangor, MI

    I've got around the problem by removing any returned results where the 'countryRegion' isn't set to 'United Kingdom', but it would be nice if the service actually worked as described! On the other hand, I could be missing something obvious, so any help would be appreciated.

    Friday, July 1, 2016 3:43 PM

Answers

  • The bounding box parameter in the Search and Autosuggest modules and also in the REST geocoding service, does not limit the result to a specific area. The bounding box is used to help weight results to the most likely expected results for an area, based on what users in those areas typically search for. Note, that this is how these services have always used this parameter. I have updated the wording in the documentation to make this clearer.

    None of these services provide an option to limit the results to a single country, however this is something that may be added to the Autosuggest module in the future.


    [Blog] [twitter] [LinkedIn]

    • Proposed as answer by Ricky_Brundritt Friday, July 1, 2016 4:05 PM
    • Marked as answer by gwenci Friday, July 1, 2016 4:08 PM
    Friday, July 1, 2016 4:05 PM

All replies

  • The bounding box parameter in the Search and Autosuggest modules and also in the REST geocoding service, does not limit the result to a specific area. The bounding box is used to help weight results to the most likely expected results for an area, based on what users in those areas typically search for. Note, that this is how these services have always used this parameter. I have updated the wording in the documentation to make this clearer.

    None of these services provide an option to limit the results to a single country, however this is something that may be added to the Autosuggest module in the future.


    [Blog] [twitter] [LinkedIn]

    • Proposed as answer by Ricky_Brundritt Friday, July 1, 2016 4:05 PM
    • Marked as answer by gwenci Friday, July 1, 2016 4:08 PM
    Friday, July 1, 2016 4:05 PM
  • Thanks for the clarification. My workaround does get around the issue, but it's good to know that I'm not doing something wrong.

     Just to add, the guidance on https://msdn.microsoft.com/en-us/library/hh868060.aspx says that the 'bounds' parameter is "A location rectangle that defines the boundaries of the area in which to search for location results.", which is a bit misleading.
    • Edited by gwenci Friday, July 1, 2016 4:10 PM
    Friday, July 1, 2016 4:07 PM
  • That page is likely cached in your browser. Before I made my post I updated the description as follows: A location rectangle that defines a boundary that is used to influence the weight of the search results. This will often change the order of results such that more relevant results to users of the specified area appear higher in the results. By default the current bounds of the map view is used by the SearchManager.

    [Blog] [twitter] [LinkedIn]

    Friday, July 1, 2016 7:46 PM