【发布时间】:2022-01-03 12:58:08
【问题描述】:
我已经做了下面的功能。这行不通。地图上不会出现点。
我给函数的参数值。
function getinfo_sendquestionzasobyeduall(anypath, webagent, froms, next, select, radius) {
$.ajax({
type: "GET",
url: anypath, //url to file.php
contentType: "application/json; charset=utf-8",
dataType:'json',
success: function(json) {
for (var klucz in json) {
var wiersz = json[klucz];
var zmienna5V1 = wiersz[41];
var zmienna6H1 = wiersz[42];
//alert('latin:'+zmienna5V1+' longin:'+zmienna6H1);
//show me info about geting sucess -is OK //
//next i parametresion function below
addlocationbingmap(zmienna5V1,zmienna6H1);
}
},
error: function(error) {
}
});
}
在函数中我不会向地图添加点但不起作用
function addlocationbingmap(geoV1,geoH1)
{
var navigationBarMode = Microsoft.Maps.NavigationBarMode;
var map = new Microsoft.Maps.Map('#oringseriesmap',
{
//你的 api 密钥在哪里
credentials: 'MY API KEY',
center: mapCentre,
navigationBarMode: navigationBarMode.compact,
supportedMapTypes: [
Microsoft.Maps.MapTypeId.road,
Microsoft.Maps.MapTypeId.aerial,
Microsoft.Maps.MapTypeId.grayscale,
Microsoft.Maps.MapTypeId.canvasLight
]
});
// to value geoV1 and geoH1
var mylocation = new Microsoft.Maps.Location(parseFloat(geoV1), parseFloat(geoH1));
// push pin to map
var pushpin = new Microsoft.Maps.Pushpin(mylocation, { text: '0', title: '1', subTitle: '', color: '#F00'});
map.entities.push(pushpin);
}
在文件 *.html 中:
<script type='text/javascript' src='https://www.bing.com/api/maps/mapcontrol' async defer></script>
【问题讨论】:
-
for循环中是否有函数声明 (addlocationbingmap)? -
我编辑代码的那一刻
-
你能把版面改得更好吗?使用适当的缩进,将代码的解释与实际代码分开,或者将它们作为 cmets(使用
//)放在代码中。 -
我改进了布局,下次请尝试自己做,它会帮助我们帮助你。
-
我改进了问题,但我自己无法回答。
标签: javascript html bing-maps