传单从 USPS EDDM 路线 JSON 数据创建地图/多边形

Leaflet create map / polygon from USPS EDDM route JSON data

我对传单很陌生,很难从 post 办公室 EDDM API[=14] 的 JSON 数据中找到有关如何在地图上创建多边形和信息的信息=]

这是一些示例数据 https://gis.usps.com/arcgis/rest/services/EDDM/selectZIP/GPServer/routes/execute?f=json&env%3AoutSR=4326&ZIP=33510&Rte_Box=R&UserName=EDDM

我正在创建类似的东西,我只需要弄清楚如何让 JSON 数据显示在地图上。只是在寻找一个开始的地方。
http://www.imagemedia.com/emap/emap.html

我只有一张以以下代码开头的空白地图

    var BING_KEY = 'XXXXXXXXX';
    var map = L.map('map').setView([27.956046, -82.312629], 15);
    var bingLayer = L.tileLayer.bing(BING_KEY).addTo(map);

您似乎可以轻松地从该数据源获取 features.geometry.path 并将其推送到传单 geoJSON 层中,而不会遇到太多麻烦。数据好像是MultiLineString:

var uspsGeoJSON = L.geoJson().addTo(map);

uspsGeoJSON.addData({
    "type": "Feature",
    "properties": usps_features["attributes"],
    "geometry": {
        "type": "MultiLineString",
        "coordinates": usps_features["geometry"]["paths"]
    }
});

这应该让你开始:

http://jsfiddle.net/nb3ue10p/