0

過去にポリマップを使用したことがありますが、余分な肥大化やライブラリの依存関係なしに geojson からマップを生成する非常に単純なスクリプトを教えてもらえますか?

geojson を含む country.json ファイルがあり、d3、openLayers、またはその他のライブラリを使用せずにマップをレンダリングしたいと考えています。

4

1 に答える 1

0

これはスタンドアロンのスクリプトではなくライブラリですが、私は過去にOpenLayersを使用しました。使い方はとても簡単で、GeoJsonで動作します。

彼らのウェブサイトのもかなり役に立ちます。彼らのGeoJsonの例から:


map = new OpenLayers.Map( 'map' );
            layer = new OpenLayers.Layer.WMS( "OpenLayers WMS", 
                    "http://vmap0.tiles.osgeo.org/wms/vmap0",
                    {layers: 'basic'} );
            map.addLayer(layer);
            map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
            var featurecollection = {
              "type": "FeatureCollection", 
              "features": [
                {"geometry": {
                    "type": "GeometryCollection", 
                    "geometries": [
                        {
                            "type": "LineString", 
                            "coordinates": 
                                [[11.0878902207, 45.1602390564], 
                                [15.01953125, 48.1298828125]]
                        }, 
                        {
                            "type": "Polygon", 
                            "coordinates": 
                                [[[11.0878902207, 45.1602390564], 
                                  [14.931640625, 40.9228515625], 
                                  [0.8251953125, 41.0986328125], 
                                  [7.63671875, 48.96484375], 
                                  [11.0878902207, 45.1602390564]]]
                        },
                        {
                            "type":"Point", 
                            "coordinates":[15.87646484375, 44.1748046875]
                        }
                    ]
                }, 
                "type": "Feature", 
                "properties": {}}
              ]
           };
           var geojson_format = new OpenLayers.Format.GeoJSON();
           var vector_layer = new OpenLayers.Layer.Vector(); 
           map.addLayer(vector_layer);
           vector_layer.addFeatures(geojson_format.read(featurecollection));
于 2012-10-25T13:24:35.963 に答える