1 | <html>
|
---|
2 | <head>
|
---|
3 | <title>OpenLayers Demo</title>
|
---|
4 | <style type="text/css">
|
---|
5 | html, body, #basicMap {
|
---|
6 | width: 100%;
|
---|
7 | height: 100%;
|
---|
8 | margin: 0;
|
---|
9 | }
|
---|
10 | </style>
|
---|
11 | <!-- <script src="http://www.openlayers.org/api/OpenLayers.js"></script> -->
|
---|
12 | <script src="http://openlayers.org/dev/OpenLayers.js"</script>
|
---|
13 |
|
---|
14 | <script>
|
---|
15 | function init() {
|
---|
16 | map = new OpenLayers.Map("basicMap");
|
---|
17 | var mapnik = new OpenLayers.Layer.OSM();
|
---|
18 | map.addLayer(mapnik);
|
---|
19 |
|
---|
20 | //layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
|
---|
21 | // "http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
|
---|
22 | //map.addLayer(layer);
|
---|
23 | //var pois = new OpenLayers.Layer.Text( "My Points",
|
---|
24 | // { location:"./textfile.txt",
|
---|
25 | // projection: map.displayProjection
|
---|
26 | // });
|
---|
27 | //map.addLayer(pois);
|
---|
28 |
|
---|
29 | var kml = new OpenLayers.Layer.GML("KML", "./kmlfile.kml",
|
---|
30 | { format: OpenLayers.Format.KML,
|
---|
31 | formatOptions: {
|
---|
32 | extractStyles: true,
|
---|
33 | extractAttributes: true,
|
---|
34 | maxDepth: 2
|
---|
35 | }
|
---|
36 | });
|
---|
37 | map.addLayer(kml);
|
---|
38 |
|
---|
39 |
|
---|
40 | //var vectors = new OpenLayers.Layer.Vector("Vector Layer")
|
---|
41 | //map.addLayer(vectors);
|
---|
42 | //map.addControl(new OpenLayers.Control.MousePosition());
|
---|
43 | //map.addControl(new OpenLayers.Control.EditingToolbar(vectors));
|
---|
44 |
|
---|
45 | //var in_options = {
|
---|
46 | // 'internalProjection': map.baseLayer.projection,
|
---|
47 | // 'externalProjection': new OpenLayers.Projection("EPSG:4326")
|
---|
48 | //};
|
---|
49 | //var wkt = new OpenLayers.Format.WKT(in_options);
|
---|
50 | //var txtFile = new XMLHttpRequest();
|
---|
51 | //txtFile.open("GET", "./wktfile.txt", false);
|
---|
52 | //// txtFile.onreadystatechange = function() {
|
---|
53 | //// if(txtFile.readyState == 4) {
|
---|
54 | //// alert(txtFile.responseText);
|
---|
55 | //// }
|
---|
56 | //// }
|
---|
57 | //txtFile.send(null);
|
---|
58 |
|
---|
59 | //var features = wkt.read(txtFile.responseText.replace(/\n/g,''));
|
---|
60 | //var bounds;
|
---|
61 | //
|
---|
62 | //if (features) {
|
---|
63 | // if(features.constructor != Array) {
|
---|
64 | // features = [features];
|
---|
65 | // }
|
---|
66 | // for(var i=0; i<features.length; ++i) {
|
---|
67 | // if (!bounds) {
|
---|
68 | // bounds = features[i].geometry.getBounds();
|
---|
69 | // }
|
---|
70 | // bounds.extend(features[i].geometry.getBounds());
|
---|
71 | // }
|
---|
72 | // vectors.addFeatures(features);
|
---|
73 | // map.zoomToExtent(bounds);
|
---|
74 | //} else {
|
---|
75 | // alert("ERROR in WTK");
|
---|
76 | //}
|
---|
77 |
|
---|
78 | map.setCenter(new OpenLayers.LonLat(4.40,52.186) // Center of the map
|
---|
79 | .transform(
|
---|
80 | new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984
|
---|
81 | new OpenLayers.Projection("EPSG:900913") // to Spherical Mercator Projection
|
---|
82 | ), 11 // Zoom level
|
---|
83 | );
|
---|
84 | }
|
---|
85 | </script>
|
---|
86 | </head>
|
---|
87 | <body onload="init();">
|
---|
88 | <div id="basicMap"></div>
|
---|
89 | </body>
|
---|
90 | </html>
|
---|