Fix attribution strings.
[rails.git] / public / export / embed.html
1 <html xmlns="http://www.w3.org/1999/xhtml">
2   <head>
3     <style type="text/css">
4         #map {
5             width: 100%;
6             height: 100%;
7         }
8         .olControlAttribution {
9             bottom: 3px!important;
10         }
11     </style>
12     <script src="http://openstreetmap.org/openlayers/OpenLayers.js"></script>
13     <script src="http://openstreetmap.org/openlayers/OpenStreetMap.js"></script>
14     <script type="text/javascript">
15         var map, layer;
16         function localUpdateLink() {
17             var center = this.map.getCenter();
18
19             // Map not initialized yet. Break out of this function.
20             if (!center) {
21                 return;
22             }
23
24             var params = OpenLayers.Util.getParameters(this.base);
25
26             params.zoom = this.map.getZoom();
27             var lat = center.lat;
28             var lon = center.lon;
29
30             if (this.displayProjection) {
31                 var mapPosition = OpenLayers.Projection.transform(
32                   { x: lon, y: lat },
33                   this.map.getProjectionObject(),
34                   this.displayProjection );
35                 lon = mapPosition.x;
36                 lat = mapPosition.y;
37             }
38
39             if (this.map.marker) {
40                 params.lat = Math.round(lat*100000)/100000;
41                 params.lon = Math.round(lon*100000)/100000;
42             } else {
43                 params.mlat = Math.round(lat*100000)/100000;
44                 params.mlon = Math.round(lon*100000)/100000;
45             }
46
47             var href = this.base;
48             if(href.indexOf('?') != -1) {
49                 href = href.substring( 0, href.indexOf('?') );
50             }
51
52             href += '?' + OpenLayers.Util.getParameterString(params);
53             this.element.href = href;
54         }
55
56         function init(){
57             OpenLayers.Lang.en.permalink = "Larger Map";
58             map = new OpenLayers.Map ("map", {
59               controls: [
60                   new OpenLayers.Control.Attribution(),
61                   new OpenLayers.Control.ArgParser(),
62                   new OpenLayers.Control.Navigation(),
63                   new OpenLayers.Control.Permalink(null, "http://openstreetmap.org/", { updateLink: localUpdateLink })
64               ],
65               maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,
66                                                20037508.34,20037508.34),
67               numZoomLevels: 20,
68               maxResolution: 156543.0339,
69               displayProjection: new OpenLayers.Projection("EPSG:4326"),
70               units: 'm',
71               projection: new OpenLayers.Projection("EPSG:900913")
72             });
73
74             var mapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik", {
75                displayOutsideMaxExtent: true,
76                wrapDateLine: true,
77                attribution: 'Data by <a target="_parent" href="http://www.openstreetmap.org">OpenStreetMap</a>'
78             });
79             map.addLayer(mapnik);
80
81             var osmarender = new OpenLayers.Layer.OSM.Osmarender("Osmarender", {
82                displayOutsideMaxExtent: true,
83                wrapDateLine: true,
84                attribution: 'Data by <a target="_parent" href="http://www.openstreetmap.org">OpenStreetMap</a>'
85             });
86             map.addLayer(osmarender);
87
88             var args = OpenLayers.Util.getParameters();
89             if (args.marker && map.getCenter()) {
90                 var markers = new OpenLayers.Layer.Markers();
91                 map.addLayer(markers);
92                 markers.addMarker( new OpenLayers.Marker(map.getCenter()));
93                 map.marker = true;
94             }
95
96             if (!map.getCenter()) { 
97                 map.zoomToMaxExtent();
98             }
99
100             var size = map.getSize();
101             if (size.h > 320) {
102                 map.addControl(new OpenLayers.Control.PanZoomBar());
103             } else {
104                 map.addControl(new OpenLayers.Control.PanZoom());
105             }
106         }
107     </script>
108   </head>
109   <body onload="init()">
110     <div id="map"></div>
111   </body>
112 </html>