]> dev.renevier.net Git - syp.git/blob - openlayers/tests/manual/geojson-geomcoll-reprojection.html
initial commit
[syp.git] / openlayers / tests / manual / geojson-geomcoll-reprojection.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4     <head>
5         <style type="text/css" media="screen">
6             #map { height: 500px; }
7         </style>
8         <script src="../../lib/OpenLayers.js" type="text/javascript" charset="utf-8"></script>
9         <script src="http://www.openstreetmap.org/openlayers/OpenStreetMap.js" type="text/javascript" charset="utf-8"></script>
10         <script type="text/javascript" charset="utf-8">
11             function init(){
12                 var map = new OpenLayers.Map ("map", {
13                     controls: [
14                         new OpenLayers.Control.Navigation(),
15                         new OpenLayers.Control.Attribution()
16                     ],
17                     maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
18                     maxResolution: 156543.0399,
19                     numZoomLevels: 19,
20                     units: 'm',
21                     projection: new OpenLayers.Projection("EPSG:900913"),
22                     displayProjection: new OpenLayers.Projection("EPSG:4326")
23                 });
24                 
25                 var osm = new OpenLayers.Layer.OSM.Mapnik('OSM');
26                 map.addLayer(osm);
27                 var lonLat = new OpenLayers.LonLat(5, 40).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject());
28                 map.setCenter (lonLat, 5);
29                 
30                 var featurecollection = {
31                     "type": "FeatureCollection", 
32                     "features": [{
33                         "geometry": {
34                             "type": "GeometryCollection", 
35                             "geometries": [
36                                 {
37                                     "type": "LineString", 
38                                     "coordinates": 
39                                         [[11.0878902207, 45.1602390564], 
40                                         [15.01953125, 48.1298828125]]
41                                 },
42                                 {
43                                     "type": "Polygon", 
44                                     "coordinates": 
45                                         [[[11.0878902207, 45.1602390564], 
46                                           [14.931640625, 40.9228515625], 
47                                           [0.8251953125, 41.0986328125], 
48                                           [7.63671875, 48.96484375], 
49                                           [11.0878902207, 45.1602390564]]]
50                                 },
51                                 {
52                                     "type":"Point", 
53                                     "coordinates":[15.87646484375, 44.1748046875]                                    
54                                 }
55                             ]
56                         }, 
57                         "type": "Feature", 
58                         "properties": {}    
59                     }]
60                 };
61                 var geojson_format = new OpenLayers.Format.GeoJSON({
62                     'internalProjection': new OpenLayers.Projection("EPSG:900913"),
63                     'externalProjection': new OpenLayers.Projection("EPSG:4326")
64                 });
65                 var vector_layer = new OpenLayers.Layer.Vector(); 
66                 map.addLayer(vector_layer);
67                 vector_layer.addFeatures(geojson_format.read(featurecollection));
68             };
69         </script>
70     </head>
71     <body onload="init()">
72         <div id="map"></div>
73     </body>
74 </html>