首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >诺基亚OVI地图自动补全功能

诺基亚OVI地图自动补全功能
EN

Stack Overflow用户
提问于 2012-03-06 02:32:49
回答 2查看 736关注 0票数 3

我正在使用google API自动完成用户地址的功能。而且它工作得很好。但现在我想使用诺基亚OVI地图的地址自动补全功能。

请告诉我如何实现相同的功能。

我正在使用下面的代码

代码语言:javascript
复制
<div id="customSearchBox" class="main-search">
        <span class ="caption">Search For Places:</span>
        <div module="SearchBox">
            <input rel="searchbox-input" class="search-box-bckgrnd" type="text" />
            <div rel="searchbox-list" class="search-list"></div>
        </div>
    </div>
    <script>
        var customSearchBox = new nokia.places.widgets.SearchBox({
            targetNode: 'customSearchBox',
            template: 'customSearchBox',
            searchCenter: function () {
                return {
                    latitude: 52.516274,
                    longitude: 13.377678
                }
            },
            onResults: function (data) {
               //here you have access to data
               alert(data);
            }
        });   
    </script>

How to get lat,这段代码很长

感谢Shivam

EN

Stack Overflow用户

发布于 2012-05-20 17:00:25

对于jQuery,您可以使用文本字段这样做,因为我不想使用预定义的“搜索框小部件”:

代码语言:javascript
复制
$('#location_address').autocomplete({
    focus:function (event, ui) {
        return false;
    },
    search:function () {
        $(this).addClass('working');
    },
    open:function () {
        $(this).removeClass('working');
    },
    select:function (event, ui) {
        var position = ui.item.id.split(";");
        var coord = new nokia.maps.geo.Coordinate(parseFloat(position[0]), parseFloat(position[1])) 

        $('#location_address').val(ui.item.label)
        $('#location_longitude')[0].value = coord.longitude;
        $('#location_latitude')[0].value = coord.latitude;
        map.setCenter(coord, "default");
        map.setZoomLevel(16); 
    },
    source:function (request, response) {
        var searchCenter = {
            latitude:52.516274,
            longitude:13.377678
        };
        nokia.places.search.manager.findPlaces({
            searchTerm:request.term,
            onComplete:function (data, status) {

                var nData = data.results.map(function (val, i) {
                    return {
                        value:val.place.name,
                        id:val.place.location.position.latitude + ";" + val.place.location.position.longitude
                    };
                })
                response(nData);

            },
            searchCenter:searchCenter,
            didYouMean:5
        });
    },
    minLength:2
});
票数 0
EN
查看全部 2 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9571953

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档