【问题标题】:How to plot shapefiles on Bing Map如何在 Bing 地图上绘制 shapefile
【发布时间】:2013-08-29 13:52:29
【问题描述】:

如何在不使用任何第三方参考的情况下将 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 地图上绘制一个多边形。但是当我尝试动态创建这些多边形时,我上面的代码不起作用。 它不会在地图上绘制任何多边形,也不会给出我的错误..

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

【问题讨论】:

  • 您需要提供更多关于您正在尝试执行的操作的信息。请发布您目前所拥有的,代码非常有帮助。
  • 现在我已经使用以下链接加载了一个基本的 bing 地图:
  • msdn.microsoft.com/en-us/library/gg427624.aspx 现在我有一个新泽西地区的 shapefile(.shp)。我想使用该 shapefile 在 bing 地图上突出显示新球衣区域,或者我们可以说无论我在该 shapefile(.shp) 中拥有什么地理空间数据,我都想根据 Bing 地图上的该 shapefile 创建一个图层。

标签: gis shapefile bing-maps


【解决方案1】:
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-10-18
  • 1970-01-01
  • 1970-01-01
  • 2020-01-11
相关资源
最近更新 更多