创建交互式地图传单-ajax

时间:2016-02-27 10:03:59

标签: javascript html ajax leaflet openstreetmap

为了创建一个由多个图层组成的交互式地图,我使用插件leaflet-ajax下载文件。 GeoJSON的。当你指向图层的对象时,属性信息(对象s attributes) displays. It is required to include a link to the html page in a number of the object的属性。我一周就把这个任务绞尽脑汁,请帮助我知道怎么做! 代码如下。

   {
    "type": "FeatureCollection",
    "crs": {
        "type": "name",
        "properties": {
            "name": "urn:ogc:def:crs:OGC:1.3:CRS84"
        }
    },

    "features": [{
        "type": "Feature",
        "properties": {
            "id": 2,
            "date": "2012\/02\/05",
            "material": "plastic",
            "Number": 1,
            "support,feeder": "2 2"
        },
        "geometry": {
            "type": "MultiPoint",
            "coordinates": [
                [34.377387101428354, 54.063054027736584]
            ]
        }
    }, {
        "type": "Feature",
        "properties": {
            "id": 4,
            "date": "2012\/02\/05",
            "material": "plastic",
            "Number": 1,
            "support , feeder": "4 2"
        },
        "geometry": {
            "type": "MultiPoint",
            "coordinates": [
                [34.378052287959541, 54.062481025595972]
            ]
        }
    }, ]
}

1 个答案:

答案 0 :(得分:0)

看起来这种情况正在发生,因为您实际上从未将图层添加到地图中。确保在初始化后为每个AJAX图层添加map.addLayer(dorogi)

或者您可以观看data:loaded事件,并在下载完所有数据后添加它们。 https://github.com/calvinmetcalf/leaflet-ajax

的文档