Геокодирование javascript для Nokia здесь не возвращает английский адрес

Я начинаю использовать Nokia Maps API и заметил некоторые странности при геокодировании адресов (получение широты/долготы адреса).

Я искал "1348 Louvain-la-Neuve,Бельгия,Бельгия"

который вернул мне один результат в массиве с адресом и позицией; К сожалению, возвращенный адрес, кажется, на французском языке, а не на моем естественном английском языке.

адресная часть возврата вернула мне значение страны «Бельгия» вместо ожидаемого «Бельгия». Есть ли способ форсировать мою английскую локаль, а не то, что кажется локалью искомой страны.

(Я также понимаю, что это может быть не проблема локали, а скорее официальное название страны, которое все еще является проблемой для меня, поскольку я говорю на английском языке)


person Jarede    schedule 27.03.2013    source источник
comment
Нокия здесь? Типа, вся компания?   -  person Stefano Borini    schedule 27.03.2013
comment
У Nokia есть платформа для карт и тому подобного, которая называется ЗДЕСЬ developer.here.com/en_GB.   -  person Jarede    schedule 27.03.2013
comment
Хорошо :) не знал этого, спасибо... оказался забавным каламбуром.   -  person Stefano Borini    schedule 27.03.2013


Ответы (1)


Это ошибка (номер тикета: JSLA-3608). Должно быть так, что добавление nokia.Settings.set("defaultLanguage", "en-GB"); изменяет локаль запроса геокодирования, но мне кажется, что функция геокодирования не передает локаль службе геокодирования. Как ни странно, служба reverseGeocoding действительно правильно передает языковой стандарт, поэтому можно использовать обходной путь для получения предпочтительного языкового стандарта:

searchManager.geoCode({
        searchTerm: "1348 Louvain-la-Neuve,Belgium,Belgium",
        onComplete: function (data, requestStatus, requestId) {
            processResults(data, requestStatus, requestId);
            map.zoomTo(addressesContainer.getBoundingBox());
            }
    });

возвращает "Бельгия"

тогда как:

searchManager.geoCode({
        searchTerm: "1348 Louvain-la-Neuve,Belgium,Belgium",
        onComplete: function (data, requestStatus, requestId) {
                    nokia.places.search.manager.reverseGeoCode({
                    latitude: data.location.position.latitude,
                    longitude: data.location.position.longitude,
                    onComplete: function (data, status) {
                         processResults(data, requestStatus, requestId);
                        map.zoomTo(addressesContainer.getBoundingBox());
                    }
                });             
            }
    });

возвращает «Бельгия».

Вот пример полностью (используйте свой собственный идентификатор приложения и токен)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <meta http-equiv="X-UA-Compatible" content="IE=7; IE=EmulateIE9; IE=EmulateIE10;"/>
            <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
            <title>Nokia Maps API for JavaScript Example: Addresses</title>
            <meta name="description" content="Geocode multiple addresses and display them using standard markers and infobubbles"/>
            <meta name="keywords" content="addresses, services, geocode, reverse, geocode"/>
            <!-- For scaling content for mobile devices, setting the viewport to the width of the device-->
            <meta name=viewport content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
            <!-- Styling for example container (NoteContainer & Logger)  -->
            <link rel="stylesheet" type="text/css" href="http://developer.here.com/apiexplorer/examples/templates/js/exampleHelpers.css"/>
            <!-- By default we add ?with=all to load every package available, it's better to change this parameter to your use case. Options ?with=maps|positioning|places|placesdata|directions|datarendering|all -->
            <script type="text/javascript" charset="UTF-8" src="http://api.maps.nokia.com/2.2.4/jsl.js?with=all"></script>
            <!-- JavaScript for example container (NoteContainer & Logger)  -->

            <style type="text/css">
                html {
                    overflow:hidden;
                }

                body {
                    margin: 0;
                    padding: 0;
                    overflow: hidden;
                    width: 100%;
                    height: 100%;
                    position: absolute;
                }

                #mapContainer {
                    width: 100%;
                    height: 100%;
                    left: 0;
                    top: 0;
                    position: absolute;
                }
            </style>
        </head>
        <body>
            <div id="mapContainer"></div>
            <div id="uiContainer"></div>
            <script type="text/javascript" id="exampleJsSource">
    /*  Set authentication token and appid 
    *   WARNING: this is a demo-only key
    *   please register on http://api.developer.nokia.com/ 
    *   and obtain your own developer's API key 
    */
    nokia.Settings.set("appId", "APP ID); 
    nokia.Settings.set("authenticationToken", "TOKEN");
    nokia.Settings.set("defaultLanguage", "en-GB");

    // Get the DOM node to which we will append the map
    var mapContainer = document.getElementById("mapContainer");

    // We create a new instance of InfoBubbles bound to a variable so we can call it later on
    var infoBubbles = new nokia.maps.map.component.InfoBubbles();

    // Create a map inside the map container DOM node
    var map = new nokia.maps.map.Display(mapContainer, {
        // initial center and zoom level of the map
        center: [52.51, 13.4],
        zoomLevel: 10,
        components:[
            // We add the behavior component to allow panning / zooming of the map
            new nokia.maps.map.component.Behavior(),
            infoBubbles
        ]
    });

    var location2,

        // We will put our address markers into this container zo we can zoom in to the markers
        addressesContainer = new nokia.maps.map.Container(),
        marker,
        searchCenter = new nokia.maps.geo.Coordinate(52.51, 13.4),
        searchManager = nokia.places.search.manager;

    map.objects.add(addressesContainer);

    var processResults = function (data, requestStatus, requestId) {
        // Data is instance of nokia.places.objects.Place 
        var location = data.location;
        // Ensure that we our request came back with valid result
        if (requestStatus == "OK") {
            // Create a new marker on the found location
            marker = new nokia.maps.map.StandardMarker(location.position);
            // Add marker to its container so it will be render
            addressesContainer.objects.add(marker); 
            marker.$address = location.address;
            marker.$label = data.name;
        }
    };

    /*
        searchManager.geoCode({
            searchTerm: "1348 Louvain-la-Neuve,Belgium,Belgium",
            onComplete: function (data, requestStatus, requestId) {
                processResults(data, requestStatus, requestId);
                map.zoomTo(addressesContainer.getBoundingBox());
                }
        }); */


        searchManager.geoCode({
            searchTerm: "1348 Louvain-la-Neuve,Belgium,Belgium",
            onComplete: function (data, requestStatus, requestId) {
                        nokia.places.search.manager.reverseGeoCode({
                        latitude: data.location.position.latitude,
                        longitude: data.location.position.longitude,
                        onComplete: function (data, status) {
                             processResults(data, requestStatus, requestId);
                            map.zoomTo(addressesContainer.getBoundingBox());
                        }
                    });             
                }
        }); 


    addressesContainer.addListener("click", function (evt) {
        var marker = evt.target,
            address = marker.$address,
            label = marker.$label;  
        if (marker instanceof nokia.maps.map.Marker) {
            infoBubbles.openBubble(label, marker.coordinate);
        }

    });




            </script>
        </body>
    </html>
person Jason Fox    schedule 08.04.2013
comment
Текущая версия HERE Maps (2.5.3), кажется, имеет ту же ошибку, возможно ли это? - person Flea777; 15.10.2013