]> dev.renevier.net Git - syj.git/blob - public/js/syjraw.js
3606018658cb7560ab22918a3227e589ac221396
[syj.git] / public / js / syjraw.js
1 var WGS84 = new OpenLayers.Projection("EPSG:4326");
2 var Mercator = new OpenLayers.Projection("EPSG:900913");
3
4 var styleMap = {
5     view: new OpenLayers.StyleMap({
6         "default": new OpenLayers.Style({
7             strokeColor: "blue",
8             strokeWidth: 5,
9             strokeOpacity: 0.7
10         })
11     })
12 };
13
14 function resizeMap() {
15     var map = document.getElementById('map');
16     map.style.width = map.offsetWidth.toString() + 'px';
17     map.style.height = map.offsetHeight.toString() + 'px';
18 }
19
20 function init() {
21     var map = new OpenLayers.Map('map', {
22                 controls: [
23                     new OpenLayers.Control.Navigation(),
24                     new OpenLayers.Control.Attribution()
25                 ],
26                 theme: null}),
27
28          baseLayer = new OpenLayers.Layer.OSM("OSM", null, { attribution: SyjStrings.osmAttribution }),
29
30          layerOptions = {format:     OpenLayers.Format.WKT,
31                         projection: WGS84,
32                         styleMap:   styleMap.view,
33                         attribution: SyjStrings.geomAttribution },
34
35         viewLayer = new OpenLayers.Layer.Vector("View Layer", layerOptions),
36         wkt = new OpenLayers.Format.WKT({ internalProjection: Mercator, externalProjection: WGS84 });
37
38     map.addLayers([baseLayer, viewLayer]);
39     viewLayer.addFeatures([wkt.read(gInitialGeom.data)]);
40     extent = viewLayer.getDataExtent();
41     map.updateSize();
42     map.zoomToExtent(extent);
43     resizeMap();
44 }
45
46 window.onresize = function() {
47     resizeMap();
48 };
49
50 if (window.addEventListener) {
51     window.addEventListener("load", init, false);
52 } else {
53     window.attachEvent("onload", init);
54 }