>On Sun, Mar 30, 2008 at 06:11:05PM +0100, Bjorn Sandvik wrote:
>>/ Hi,
/>>/ 
/>>/ I'm looking at possibilities of using OpenLayers for thematic mapping 
/>>/ (thematicmapping.org), and I think GeoJSON might be a suitable format 
/>>/ for choropleth maps.
/>>/ 
/>>/ I'm able to generate GeoJSON on the server using PHP, and my country 
/>>/ polygons are rendered in OpenLayers when I'm pasting the GeoJSON code 
/>>/ on: http://www.openlayers.org/dev/examples/vector-formats.html
/>>/ 
/>>/ My question: What is the best way to load and render a GeoJSON layer in 
/>>/ OpenLayers?
/>
> new OpenLayers.Layer.GML("My GeoJSON Layer", "/file.geojson", 
>  {format: OpenLayers.Format.GeoJSON}); 
>
> Regards,
> -- 
> Christopher Schmidt
> MetaCarta

Thanks, it works. Is it also possible to load a GeoJSON file using the read 
function?

        map = new OpenLayers.Map('map');
        var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
                "http://labs.metacarta.com/wms/vmap0?";, {layers: 'basic'});
        vectors = new OpenLayers.Layer.Vector("Vector Layer");
        map.addLayers([wms, vectors]);
            
        var parser = new OpenLayers.Format.GeoJSON();
        var features = parser.read("filename");
        ...

See last line. 
I guess I can more easily manipulate the features this way.

Bjorn

http://blog.thematicmapping.org


_______________________________________________
Users mailing list
[email protected]
http://openlayers.org/mailman/listinfo/users

Reply via email to