Javascript 如何获得地图中显示的左上角、右下角的纬度和经度?

Javascript 如何获得地图中显示的左上角、右下角的纬度和经度?,javascript,here-api,Javascript,Here Api,我想使用边界框调用nokia.places.search.manager.findPlaces。我希望边界框与页面上显示的地图相对应。我找不到我所期望的方法。您所追求的方法是。引用API参考资料: 此方法检索地图视图的外部边界框( 覆盖所有可见点的最小边界框) 下面是一个在位置搜索中使用boundingBox参数的示例(当然可以使用您自己的)。如果增加显示的地图的zoomLevel,则搜索范围将缩小。重要的一点就在底部 <!DOCTYPE html PUBLIC "-//W3C//DTD

我想使用边界框调用nokia.places.search.manager.findPlaces。我希望边界框与页面上显示的地图相对应。我找不到我所期望的方法。

您所追求的方法是。引用API参考资料:

此方法检索地图视图的外部边界框( 覆盖所有可见点的最小边界框)

下面是一个在位置搜索中使用
boundingBox
参数的示例(当然可以使用您自己的)。如果增加显示的
地图的
zoomLevel
,则搜索范围将缩小。重要的一点就在底部

<!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"/>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
        <title>HERE Maps API Example: Search by bounding box</title>
        <meta name="description" content="Search by category"/>
        <meta name="keywords" content="search, services, places, category"/>
        <!-- For scaling content for mobile devices, setting the viewport to the width of the device-->
        <meta name=viewport content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
        <!-- 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.3/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: 80%;
                height: 80%;
                left: 0;
                top: 0;
                position: absolute;
            }
            #progress {
                width: 80%;
                height: 10%;
                left: 0;
                top: 80%;
                position: absolute;
            }
            #buttons {
                width: 80%;
                height: 10%;
                left: 0;
                top: 90%;
                position: absolute;
            }
        </style>
    </head>
    <body>
        <div id="mapContainer"></div>
        <div id="progress"></div>

        <script type="text/javascript" id="exampleJsSource">

nokia.Settings.set("appId", "YOUR APP ID"); 
nokia.Settings.set("authenticationToken", "YOUR TOKEN");


// Get the DOM node to which we will append the map
var mapContainer = document.getElementById("mapContainer");
// 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: 15,
    components: [       
        new nokia.maps.map.component.Behavior()
    ]
});

var searchManager = nokia.places.search.manager,
    resultSet;




// Function for receiving search results from places search and process them
var processResults = function (data, requestStatus, requestId) {
    var i, len, locations, marker;
    if (requestStatus == "OK") {
        // The function findPlaces() and reverseGeoCode() of  return results in slightly different formats
        locations = data.results ? data.results.items : [data.location];
        // We check that at least one location has been found
        if (locations.length > 0) {
            // Remove results from previous search from the map
            if (resultSet) map.objects.remove(resultSet);
            // Convert all found locations into a set of markers
            resultSet = new nokia.maps.map.Container();
            for (i = 0, len = locations.length; i < len; i++) {
                marker = new nokia.maps.map.StandardMarker(locations[i].position, { text: i+1 });
                resultSet.objects.add(marker);
            }
            // Next we add the marker(s) to the map's object collection so they will be rendered onto the map
            map.objects.add(resultSet);
            // We zoom the map to a view that encapsulates all the markers into map's viewport
            //map.zoomTo(resultSet.getBoundingBox(), true);

        } else { 
            //alert("Your search produced no results!");
        }
         searching = false;
    } else {
        alert("The search request failed");
        searching = false;
    }
};



// Binding of DOM elements to several variables so we can install event handlers.
var progressUiElt = document.getElementById("progress");


var searching = false;
search = function(boundingBox){
// Make a place search request
var category = "eat-drink"
progressUiElt.innerHTML = "Looking for places in the '" + category + "' category...'";
searchManager.findPlacesByCategory({
    category: category,
    onComplete: processResults,
    boundingBox: boundingBox,
    limit: 50,
});
}


search(map.getViewBounds());



        </script>
    </body>
</html>

这里映射API示例:按边界框搜索
html{
溢出:隐藏;
}
身体{
保证金:0;
填充:0;
溢出:隐藏;
宽度:100%;
身高:100%;
位置:绝对位置;
}
#地图容器{
宽度:80%;
身高:80%;
左:0;
排名:0;
位置:绝对位置;
}
#进展{
宽度:80%;
身高:10%;
左:0;
最高:80%;
位置:绝对位置;
}
#钮扣{
宽度:80%;
身高:10%;
左:0;
最高:90%;
位置:绝对位置;
}
nokia.Settings.set(“appId”、“您的appId”);
nokia.Settings.set(“authenticationToken”、“您的令牌”);
//获取要向其附加映射的DOM节点
var mapContainer=document.getElementById(“mapContainer”);
//在映射容器DOM节点内创建映射
var map=新的nokia.maps.map.Display(mapContainer{
//地图的初始中心和缩放级别
中间:[52.51,13.4],
zoomLevel:15,
组成部分:[
新的nokia.maps.map.component.Behavior()
]
});
var searchManager=nokia.places.search.manager,
结果集;
//用于从地点搜索接收搜索结果并对其进行处理的功能
var processResults=函数(数据、请求状态、请求ID){
变量i、len、位置、标记;
如果(请求状态=“确定”){
//return的函数findPlaces()和reverseGeoCode()的格式略有不同
位置=data.results?data.results.items:[data.location];
//我们检查是否至少找到了一个位置
如果(位置.长度>0){
//从地图中删除上一次搜索的结果
if(resultSet)map.objects.remove(resultSet);
//将找到的所有位置转换为一组标记
resultSet=new nokia.maps.map.Container();
对于(i=0,len=locations.length;i
您所追求的方法是。引用API参考资料:

此方法检索地图视图的外部边界框( 覆盖所有可见点的最小边界框)

下面是一个在位置搜索中使用
boundingBox
参数的示例(当然可以使用您自己的)。如果增加显示的
地图的
zoomLevel
,则搜索范围将缩小。重要的一点就在底部

<!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"/>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
        <title>HERE Maps API Example: Search by bounding box</title>
        <meta name="description" content="Search by category"/>
        <meta name="keywords" content="search, services, places, category"/>
        <!-- For scaling content for mobile devices, setting the viewport to the width of the device-->
        <meta name=viewport content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
        <!-- 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.3/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: 80%;
                height: 80%;
                left: 0;
                top: 0;
                position: absolute;
            }
            #progress {
                width: 80%;
                height: 10%;
                left: 0;
                top: 80%;
                position: absolute;
            }
            #buttons {
                width: 80%;
                height: 10%;
                left: 0;
                top: 90%;
                position: absolute;
            }
        </style>
    </head>
    <body>
        <div id="mapContainer"></div>
        <div id="progress"></div>

        <script type="text/javascript" id="exampleJsSource">

nokia.Settings.set("appId", "YOUR APP ID"); 
nokia.Settings.set("authenticationToken", "YOUR TOKEN");


// Get the DOM node to which we will append the map
var mapContainer = document.getElementById("mapContainer");
// 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: 15,
    components: [       
        new nokia.maps.map.component.Behavior()
    ]
});

var searchManager = nokia.places.search.manager,
    resultSet;




// Function for receiving search results from places search and process them
var processResults = function (data, requestStatus, requestId) {
    var i, len, locations, marker;
    if (requestStatus == "OK") {
        // The function findPlaces() and reverseGeoCode() of  return results in slightly different formats
        locations = data.results ? data.results.items : [data.location];
        // We check that at least one location has been found
        if (locations.length > 0) {
            // Remove results from previous search from the map
            if (resultSet) map.objects.remove(resultSet);
            // Convert all found locations into a set of markers
            resultSet = new nokia.maps.map.Container();
            for (i = 0, len = locations.length; i < len; i++) {
                marker = new nokia.maps.map.StandardMarker(locations[i].position, { text: i+1 });
                resultSet.objects.add(marker);
            }
            // Next we add the marker(s) to the map's object collection so they will be rendered onto the map
            map.objects.add(resultSet);
            // We zoom the map to a view that encapsulates all the markers into map's viewport
            //map.zoomTo(resultSet.getBoundingBox(), true);

        } else { 
            //alert("Your search produced no results!");
        }
         searching = false;
    } else {
        alert("The search request failed");
        searching = false;
    }
};



// Binding of DOM elements to several variables so we can install event handlers.
var progressUiElt = document.getElementById("progress");


var searching = false;
search = function(boundingBox){
// Make a place search request
var category = "eat-drink"
progressUiElt.innerHTML = "Looking for places in the '" + category + "' category...'";
searchManager.findPlacesByCategory({
    category: category,
    onComplete: processResults,
    boundingBox: boundingBox,
    limit: 50,
});
}


search(map.getViewBounds());



        </script>
    </body>
</html>

这里映射API示例:按边界框搜索
html{
溢出:隐藏;
}
身体{
保证金:0;
填充:0;
溢出:隐藏;
宽度:100%;
身高:100%;
位置:绝对位置;
}
#地图容器{
宽度:80%;
身高:80%;
左:0;
排名:0;
位置:绝对位置;
}
#进展{
宽度:80%;
身高:10%;
左:0;
最高:80%;
位置:绝对位置;
}
#钮扣{
宽度:80%;
身高:10%;
左:0;
最高:90%;
位置:绝对位置;
}
nokia.Settings.set(“appId”、“您的appId”);
nokia.Settings.set(“authenticat