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">
5 <style type="text/css" media="screen">
6 #map { height: 500px; }
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">
12 var map = new OpenLayers.Map ("map", {
14 new OpenLayers.Control.Navigation(),
15 new OpenLayers.Control.Attribution()
17 maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
18 maxResolution: 156543.0399,
21 projection: new OpenLayers.Projection("EPSG:900913"),
22 displayProjection: new OpenLayers.Projection("EPSG:4326")
25 var osm = new OpenLayers.Layer.OSM.Mapnik('OSM');
27 var lonLat = new OpenLayers.LonLat(5, 40).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject());
28 map.setCenter (lonLat, 5);
30 var featurecollection = {
31 "type": "FeatureCollection",
34 "type": "GeometryCollection",
39 [[11.0878902207, 45.1602390564],
40 [15.01953125, 48.1298828125]]
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]]]
53 "coordinates":[15.87646484375, 44.1748046875]
61 var geojson_format = new OpenLayers.Format.GeoJSON({
62 'internalProjection': new OpenLayers.Projection("EPSG:900913"),
63 'externalProjection': new OpenLayers.Projection("EPSG:4326")
65 var vector_layer = new OpenLayers.Layer.Vector();
66 map.addLayer(vector_layer);
67 vector_layer.addFeatures(geojson_format.read(featurecollection));
71 <body onload="init()">