如何在Bing Map上绘制shapefile

时间:2013-08-29 13:52:29

标签: gis shapefile bing-maps

如何在不使用任何第三方参考的情况下将shapefile(.shp)与bing地图一起使用? 我只是想用bing maps api库来执行这个动作。 那么建议我如何实现这个目标?

我尝试了一些bing地图,如下所述。 这是我的代码:

$.ajax({
            type: "POST",
            url: "GISFunctions.asmx/GetShapeFileData",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (data, textStatus, jqXHR) {
                var response = data.d;
                for (var i = 0; i < response.length; i++) {
                    var polygonGeometry = response[i];
                    var vertices = new Array();
                    var numCoordinates = polygonGeometry.length;
                    for (var j = 0; j < numCoordinates; j++) {
                        var CoOrdinates = polygonGeometry[j];
                        var x = CoOrdinates[1];
                        var y = CoOrdinates[0];
                        vertices[j] = new Microsoft.Maps.Location(x, y);
                    }
                    var polygoncolor = new Microsoft.Maps.Color(100, 100, 0, 100);
                    var polygon = new Microsoft.Maps.Polygon(vertices, { fillColor: polygoncolor, strokeColor: polygoncolor });
                // Add the shape to the map
                    map.entities.push(polygon);
                }
            },
            error: function (xhr, status, error) {
                alert(xhr.responseText);
            }
        });

“GISFunctions.asmx / GetShapeFileData”是我的网络服务方法。它从shapefile中获取数据。逐个读取shapefile的记录并获取每个记录多边形的坐标。 在上面的Jquery Ajax函数中,我已经区分了我的数据并创建了包含多边形顶点的数组,然后根据下面的链接,我试图在Bing Map上映射这些多边形

http://msdn.microsoft.com/en-us/library/gg427604.aspx

当我浏览静态数据时,我可以在Bing Map上轻松绘制一个多边形..但是当我尝试动态创建这些多边形时,我的上述代码不起作用。 它不会在地图上绘制任何多边形,也不会给出我的错误..

我是GIS功能的新手,所以请建议我正确的方向..