| 1 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
|---|
| 2 |
<head> |
|---|
| 3 |
<link rel="stylesheet" href="../theme/default/style.css" type="text/css" /> |
|---|
| 4 |
<link rel="stylesheet" href="style.css" type="text/css" /> |
|---|
| 5 |
<script src="../lib/OpenLayers.js"></script> |
|---|
| 6 |
<script type="text/javascript"> |
|---|
| 7 |
var lon = 5; |
|---|
| 8 |
var lat = 40; |
|---|
| 9 |
var zoom = 5; |
|---|
| 10 |
var map, layer; |
|---|
| 11 |
|
|---|
| 12 |
function init(){ |
|---|
| 13 |
map = new OpenLayers.Map( 'map' ); |
|---|
| 14 |
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS", |
|---|
| 15 |
"http://labs.metacarta.com/wms/vmap0", |
|---|
| 16 |
{layers: 'basic'} ); |
|---|
| 17 |
map.addLayer(layer); |
|---|
| 18 |
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom); |
|---|
| 19 |
var featurecollection = { |
|---|
| 20 |
"type": "FeatureCollection", |
|---|
| 21 |
"features": [ |
|---|
| 22 |
{"geometry": { |
|---|
| 23 |
"type": "GeometryCollection", |
|---|
| 24 |
"geometries": [ |
|---|
| 25 |
{ |
|---|
| 26 |
"type": "LineString", |
|---|
| 27 |
"coordinates": |
|---|
| 28 |
[[11.0878902207, 45.1602390564], |
|---|
| 29 |
[15.01953125, 48.1298828125]] |
|---|
| 30 |
}, |
|---|
| 31 |
{ |
|---|
| 32 |
"type": "Polygon", |
|---|
| 33 |
"coordinates": |
|---|
| 34 |
[[[11.0878902207, 45.1602390564], |
|---|
| 35 |
[14.931640625, 40.9228515625], |
|---|
| 36 |
[0.8251953125, 41.0986328125], |
|---|
| 37 |
[7.63671875, 48.96484375], |
|---|
| 38 |
[11.0878902207, 45.1602390564]]] |
|---|
| 39 |
}, |
|---|
| 40 |
{ |
|---|
| 41 |
"type":"Point", |
|---|
| 42 |
"coordinates":[15.87646484375, 44.1748046875] |
|---|
| 43 |
} |
|---|
| 44 |
] |
|---|
| 45 |
}, |
|---|
| 46 |
"type": "Feature", |
|---|
| 47 |
"properties": {}} |
|---|
| 48 |
] |
|---|
| 49 |
}; |
|---|
| 50 |
var geojson_format = new OpenLayers.Format.GeoJSON(); |
|---|
| 51 |
var vector_layer = new OpenLayers.Layer.Vector(); |
|---|
| 52 |
map.addLayer(vector_layer); |
|---|
| 53 |
vector_layer.addFeatures(geojson_format.read(featurecollection)); |
|---|
| 54 |
|
|---|
| 55 |
} |
|---|
| 56 |
</script> |
|---|
| 57 |
</head> |
|---|
| 58 |
<body onload="init()"> |
|---|
| 59 |
<h1 id="title">GeoJSON Example</h1> |
|---|
| 60 |
<div id="map" class="smallmap"></div> |
|---|
| 61 |
</body> |
|---|
| 62 |
</html> |
|---|