1 /* This file is part of Syj, Copyright (c) 2010-2011 Arnaud Renevier,
2 and is published under the AGPL license. */
6 var WGS84 = new OpenLayers.Projection("EPSG:4326");
7 var Mercator = new OpenLayers.Projection("EPSG:900913");
10 view: new OpenLayers.StyleMap({
11 "default": new OpenLayers.Style({
19 function resizeMap() {
20 var map = document.getElementById('map');
21 map.style.width = map.offsetWidth.toString() + 'px';
22 map.style.height = map.offsetHeight.toString() + 'px';
25 function mapquestLayer() {
26 return new OpenLayers.Layer.OSM("MapQuest", [
27 'http://otile1.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png',
28 'http://otile2.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png',
29 'http://otile3.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png',
30 'http://otile4.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png'],
31 { attribution: SyjStrings.mapquestAttribution});
34 function mapnikLayer() {
35 return new OpenLayers.Layer.OSM("Mapnik", [
36 'http://a.tile.openstreetmap.org/${z}/${x}/${y}.png',
37 'http://b.tile.openstreetmap.org/${z}/${x}/${y}.png',
38 'http://c.tile.openstreetmap.org/${z}/${x}/${y}.png'],
39 { attribution: SyjStrings.osmAttribution});
43 var map = new OpenLayers.Map('map', {
45 new OpenLayers.Control.Navigation(),
46 new OpenLayers.Control.Attribution()
50 parameters = OpenLayers.Util.getParameters(window.location.href),
53 layerOptions = {format: OpenLayers.Format.WKT,
55 styleMap: styleMap.view,
56 attribution: SyjStrings.geomAttribution },
58 viewLayer = new OpenLayers.Layer.Vector("View Layer", layerOptions),
59 wkt = new OpenLayers.Format.WKT({ internalProjection: Mercator, externalProjection: WGS84 });
61 if (parameters.layer) {
62 switch (parameters.layer.toUpperCase()) {
64 baseLayer = mapquestLayer();
67 baseLayer = mapnikLayer();
73 baseLayer = mapnikLayer();
76 map.addLayers([baseLayer, viewLayer]);
77 viewLayer.addFeatures([wkt.read(gInitialGeom.data)]);
78 var extent = viewLayer.getDataExtent();
80 map.zoomToExtent(extent);
84 window.onresize = function() {
88 if (window.addEventListener) {
89 window.addEventListener("load", init, false);
91 window.attachEvent("onload", init);