目标:
更新必应地图中的视觉位置。
问题:
如果我在文本框中添加了新的纬度和逻辑坐标,那么必应显示,但它不能工作。
信息:
*您需要使用您自己的api密钥代码。
*-http://jsbin.com/zegimofege/edit?html,console,output
谢谢!
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
<!-- Reference to the Bing Maps SDK -->
<script type='text/javascript'
src='http://www.bing.com/api/maps/mapcontrol?callback=GetMap&key=[your kep]'
async defer></script>
<script type='text/javascript'>
function GetMap()
{
var map = new Microsoft.Maps.Map('#myMap', {
credentials: 'Your Bing Maps Key',
mapTypeId: Microsoft.Maps.MapTypeId.road,
center: new Microsoft.Maps.Location(parseInt(document.getElementById("log")), parseInt(document.getElementById("lat"))),
zoom: 10
});
}
</script>
</head>
<body onload="GetMap();">
<div id="myMap" style="position:relative;width:600px;height:400px;"></div>
Log: <input type="text" id="log" value="51.50632"><br>
Lat: <input type="text" id="lat" value="-0.12714"><br>
</body>
</html>
发布于 2017-12-12 17:58:53
在更新文本框值时,您没有添加任何代码来执行任何操作。向它们添加事件。您所使用的事件取决于您,一些人需要考虑、键控、脱离焦点或添加更新按钮。在事件处理程序中,获取这些值并使用parseFloat转换为浮动,然后设置如下map.setView的映射视图({map.setView:newMicrosoft.Maps.Location(lat,lon) })
https://stackoverflow.com/questions/47775035
复制相似问题