none
Autosuggest not returning a bestView property

    Question

  • I have followed the example exactly located here:

    http://www.bing.com/api/maps/sdkrelease/mapcontrol/isdk#autoSuggestUi+JS

    and the selectedSuggestion does not return a bestView property so I cannot zoom my map to a useful level.

    Thursday, April 13, 2017 11:59 AM

All replies

  • Can you provide the query you used?

    [Blog] [twitter] [LinkedIn]

    Thursday, April 13, 2017 3:32 PM
    Owner
  • My code is below.  It's the selectedSuggestion object that is missing the besView property.

    function loadMap() {
        map = new Microsoft.Maps.Map(document.getElementById("mapHolder"), {
            credentials: "BING_MAPS_KEY",
            zoom: 10
        });
        Microsoft.Maps.Events.addHandler(map, "viewchangestart", clearMap);
        Microsoft.Maps.Events.addHandler(map, "viewchangeend", loadPins);
        infoBox = new Microsoft.Maps.Infobox(null, {
            visible: false,
            maxWidth: 500,
            maxHeight: 500
        });
        infoBox.setMap(map)
        Microsoft.Maps.loadModule('Microsoft.Maps.AutoSuggest', function () {
            var options = {
                map: map,
                useMapView: false
            };
            var manager = new Microsoft.Maps.AutosuggestManager(options);
            manager.attachAutosuggest('#searchBox', '#searchBoxContainer', selectedSuggestion);
        });
        if ($("#hdnLat").length != 0) {
            map.setView({
                center: new Microsoft.Maps.Location($("#hdnLat").val(), $("#hdnLng").val()),
                zoom: 15
            });
        } else {
            loadPins();
        }
    };
    function selectedSuggestion(result) {
        map.setView({ center: new Microsoft.Maps.Location(result.location.latitude, result.location.longitude) });
    }
    Friday, April 21, 2017 10:10 AM
  • By query, I meant the text you typed into the autosuggest textbox. Have you tried the experimental branch to see if this issue occurs there?

    [Blog] [twitter] [LinkedIn]

    Friday, April 21, 2017 2:14 PM
    Owner
  • Ah, sorry.  Now I understand.  I have tried many a query, for example London and then click on London, United Kingdom.

    I have also tried all three branches.

    Tuesday, April 25, 2017 4:07 PM
  • I'm not able to reproduce this and never have. London is one of my main test queries. I've just tested all three branches on all supported browsers and all of them worked as expected.

    [Blog] [twitter] [LinkedIn]

    Thursday, April 27, 2017 6:24 PM
    Owner
  • Sorry it has taken me so long to respond.

    It's definitely not working.  Take a look on the Bing Maps Interactive SDK example page:

    https://www.bing.com/api/maps/sdkrelease/mapcontrol/isdk#autoSuggestUi+JS

    no bestView property.

    This thread also reports the same issue.

    https://social.msdn.microsoft.com/Forums/en-US/de9f3204-b819-4f40-9849-5bbd24dc4a41/microsoftmapsautosuggestmanager-not-returning-bestview?forum=bingmapsajax

    Thanks in advance

    Thursday, May 11, 2017 2:33 PM
  • That's working. I think the issue is that the best view may be larger than you are expecting. 

    [Blog] [twitter] [LinkedIn]

    Saturday, May 13, 2017 5:37 PM
    Owner
  • No matter what I try, it doesn't work for me.  Just to be clear this is what I do:

    • visit: https://www.bing.com/api/maps/sdkrelease/mapcontrol/isdk#autoSuggestUi+JS
    • Type any location E.G New York in the text box within the "Printout Window"
    • Click on a location from the list.
    • The pin moves to the new location
    • The map does not.

    I am in the UK so not sure if it's a regional issue.  I have tried on many PC's in the office and on a variety of browsers.  I have even inspected the response and there is not a bestView property.

    Really struggling on this and appreciate any help you can give.

    Monday, May 15, 2017 10:55 AM
  • I've managed to finally reproduce this. I will log this as a bug for the team to investigate.

    [Blog] [twitter] [LinkedIn]

    Monday, May 15, 2017 4:09 PM
    Owner
  • Thanks Ricky. I thought I was losing my mind.

    Really appreciate your help.

    Monday, May 15, 2017 4:30 PM