maps - 如何在 bing 地图上显示 GeoJson 对象?
问题描述
我正在尝试调用具有位置的 api 以在 bing 地图上显示 GeoJson 对象。我在下面编写了代码,但地图上没有显示任何内容,也没有错误。
你能看看这段代码有什么问题吗?
var api = 'https://api/locations';
Microsoft.Maps.loadModule('Microsoft.Maps.GeoJson', function () {
Microsoft.Maps.GeoJson.readFromUrl(api,
function (shapes) {
//Add the shape(s) to the map.
map.entities.push(shapes);
}, 'callback');
});
谢谢
解决方案
Does the service you are calling wrap the response with JavaScript? Your code has 'callback' which is telling Bing Maps to make a JSONP request which will append &callback=[some internal callback function]
to the request. If your service doesn't use JSONP and is hosted on the same domain or is on a CORs enabled endpoint, remove the callback
parameter from your code.
推荐阅读
- javascript - 使用 Hooks 和 onChange 处理程序进行反应以进行条件渲染
- google-bigquery - 更新_未_分区但_存在_流缓冲区的表中的行
- javascript - 我正在尝试做一个自定义翻译脚本。我制作了这个脚本,用字母替换符号。但有个问题
- github - 如何在 GITHUB 中使用没有远程分支的 Terraform 更新分支保护?
- laravel - Product_id 未传递给函数
- c++ - 当我按下任一 ALT 时,WINAPI 应用程序关闭,为什么?
- html - Django:模板表单操作未重定向
- python - Python:追加/扩展方法
- ios - 如何快速制作系统字体“黑色斜体”?
- javascript - Switch 语句返回未定义