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