首页 > 解决方案 > 如何在 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');
    });

谢谢

标签: mapsgeojsonbing-maps

解决方案


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.


推荐阅读