source: extensions/rv_gmaps/trunk/template/map.tpl @ 4070

Last change on this file since 4070 was 4070, checked in by rvelices, 15 years ago

google maps api is loaded using the same language as piwigo

  • Property svn:eol-style set to LF
File size: 8.4 KB
Line 
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
3<head>
4<meta http-equiv="content-type" content="text/html; charset={$CONTENT_ENCODING}" />
5<meta name="robots" content="noindex,nofollow" />
6<title>{$GALLERY_TITLE}</title>
7<link rel="stylesheet" type="text/css" href="{$PLUGIN_ROOT_URL}/template/style.css?v={$RVM_PLUGIN_VERSION}" />
8<!--[if IE]>
9<style type="text/css">
10v\:* {ldelim}
11  behavior:url(#default#VML);
12}
13</style>
14<![endif]-->
15<!--[if lt IE 7]>
16<style type="text/css">
17        #map {ldelim} position:auto; height: 100%; }
18</style>
19<![endif]-->
20
21<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key={$GMAPS_API_KEY}&amp;hl={$lang_info.code}" type="text/javascript"></script>
22<script src="{$PLUGIN_ROOT_URL}/template/data_loader.js?v={$RVM_PLUGIN_VERSION}" type="text/javascript"></script>
23<script src="{$PLUGIN_ROOT_URL}/template/data_handler.js?v={$RVM_PLUGIN_VERSION}" type="text/javascript"></script>
24<script src="{$PLUGIN_ROOT_URL}/template/page_linker.js?v={$RVM_PLUGIN_VERSION}" type="text/javascript"></script>
25
26<script src="{$PLUGIN_ROOT_URL}/template/windows_13/javascripts/prototype.js" type="text/javascript"></script>
27<link href="{$PLUGIN_ROOT_URL}/template/windows_13/themes/default.css" rel="stylesheet" type="text/css" />
28<link href="{$PLUGIN_ROOT_URL}/template/windows_13/themes/alphacube.css" rel="stylesheet" type="text/css" />
29
30<script type="text/javascript">{literal}
31//<![CDATA[
32var map;
33var geocoder;
34
35document.is_debug = false;
36if ( document.location.search.match(/[\?&]debug/) ) {
37  document.is_debug = true;
38  document._window = window;
39}
40 
41function load()
42{
43        if (!GBrowserIsCompatible())
44        return;
45
46        var mapElement = document.getElementById("map");
47        map = new GMap2( mapElement );
48
49        map.addMapType( G_PHYSICAL_MAP );
50        map.addControl(new GLargeMapControl());
51        map.addControl(new GHierarchicalMapTypeControl());
52        map.addControl(new GScaleControl());
53
54        pwgPageLinker = new PageLinker(map, "aLinkToThisPage" );
55        if ( !map.isLoaded() )
56        {
57{/literal}
58                {if isset($initial_bounds)}
59    var bounds = new GLatLngBounds( new GLatLng({$initial_bounds.s},{$initial_bounds.w}), new GLatLng({$initial_bounds.n},{$initial_bounds.e}) );
60    map.setCenter( bounds.getCenter(), map.getBoundsZoomLevel( bounds ) );
61                {/if}
62{literal}
63                if ( !map.isLoaded() )
64                        map.setCenter( new GLatLng(0,0), 2 );
65  }
66
67  try {
68                // the overview must be added after setting map center
69                var ovcontrol = new GOverviewMapControl(new GSize(165,165));
70                map.addControl(ovcontrol);
71  }
72  catch(e){ alert( e.message ); }
73 
74        map.enableScrollWheelZoom();
75        map.enableDoubleClickZoom();
76 
77        var pwgMarkerIcon = (function(){ {/literal}{$MAP_MARKER_ICON_JS}{literal} }).call(null);
78
79        map.pwgDataLoader = new PwgDataLoader(map, {rectangle_of_confusion: pwgMarkerIcon.iconSize} );
80        GEvent.addListener(map.pwgDataLoader, "dataloading", function() {
81                var pre = '<img src="{/literal}{$PLUGIN_ROOT_URL}{literal}/icons/progress_s.gif" width="16" height="16" alt="~" /> ';
82                document.getElementById("dataLoadStatus").innerHTML = pre + Localization.get("Loading");
83                }
84        );
85 
86        GEvent.addListener(map.pwgDataLoader, "dataloadfailed", function(responseCode) {
87                document.getElementById("dataLoadStatus").innerHTML = Localization.get("Failed") + " "+responseCode;
88                }
89                );
90
91        map.pwgDataHandler = new PwgDataHandler(map, {icon: pwgMarkerIcon, show_all_img_src: "{/literal}{$PLUGIN_ROOT_URL}{literal}/icons/pic_s.gif" } );
92        GEvent.addListener(map.pwgDataLoader, "dataloaded", map.pwgDataHandler.handle.bind(map.pwgDataHandler) );
93
94        map.pwgDataLoader.start( "{/literal}{$U_MAP_DATA}{literal}" );
95
96        if (document.is_debug)
97        {
98                GEvent.addListener(map, "moveend", function() { GLog.write("movend c:"+map.getCenter().toUrlValue());} );
99                GEvent.addListener(map, "maptypechanged", function() { GLog.write("maptypechanged");} );
100                GEvent.addListener(map, "infowindowopen", function() { GLog.write("infowindowopen");} );
101                GEvent.addListener(map, "infowindowclose", function() { GLog.write("infowindowclose");} );
102  }
103}
104
105function unload()
106{
107        if (map)
108        {
109                !map.pwgDataLoader || map.pwgDataLoader.terminate();
110                !map.pwgDataHandler || map.pwgDataHandler.terminate();
111        }
112        GUnload();
113}
114
115function searchLocation(q)
116{
117        if (!q.length) return false;
118        if (!geocoder)
119                geocoder = new GClientGeocoder();
120        geocoder.getLocations(q, function(resp)
121          {
122            if ( resp && resp.Status )
123            {
124              document._geoResponse = resp;
125              if (resp.Status.code==200)
126              {
127                var zoom = 2;
128                switch (resp.Placemark[0].AddressDetails.Accuracy)
129                {
130                  case 1: zoom=5; break; //country
131                  case 2: zoom=7; break; //region
132                  case 3: zoom=8; break; //county
133                  case 4: zoom=12; break; //town
134                  case 5: zoom=13; break; //post code
135                  case 6: zoom=14; break; //street
136                  case 7: case 8: zoom=16; break; //intersection/exact
137                }
138                map.setCenter( new GLatLng( resp.Placemark[0].Point.coordinates[1], resp.Placemark[0].Point.coordinates[0] ), zoom);
139              }
140              else
141                alert("This address has not been found\nCode:"+resp.Status.code);
142            }
143          });
144        return false;
145}
146
147
148var Localization =
149{
150  _strings: {
151{/literal}
152"go to %s": "{'go to %s'|@translate|@escape:javascript}",
153"Next": "{'Next'|@translate|@escape:javascript}",
154"Prev": "{'Prev'|@translate|@escape:javascript}",
155"out of %d": "{'out of %d'|@translate|@escape:javascript}",
156"Loading": "{'Loading'|@translate|@escape:javascript}",
157"Failed": "{'Failed'|@translate|@escape:javascript}",
158"Show all": "{'Show all'|@translate|@escape:javascript}",
159"show all pictures around this location": "{'show all pictures around this location'|@translate|@escape:javascript}",
160"displays %s on a map" : "{'displays %s on a map'|@translate|@escape:javascript}",
161"opens %s in Google Earth" : "{'opens %s in Google Earth'|@translate|@escape:javascript}",
162"%d elements" : "{'%d elements'|@translate|@escape:javascript}",
163{literal}
164dontMindTheComma: ""
165    },
166
167  get: function( str ) {
168                var lang_str = this._strings[str];
169                if (lang_str == undefined)
170                {
171                        if (document.is_debug) GLog.write("Language string undefined '"+ str+"'");
172                        return str;
173                }
174                return lang_str;
175        },
176
177  getQ: function( str ) {
178                return '"'+this.get(str)+'"';
179        },
180
181  fmt1: function () {
182                var args = $A(arguments);
183                var str = args.shift();
184                str = this.get(str);
185                str = str.replace( '%s', "#\{0\}" ).replace( '%d', "#\{0\}" );
186                return new Template(str).evaluate( args );
187        }
188}
189{/literal}
190//]]>
191</script>
192</head>
193
194<body onload="load()" onunload="unload()">
195
196<div id="titlebar">
197  <div class="titlebar_links" >
198    <span id="dataLoadStatus"></span>
199    <a id="aKml" href="" type="application/vnd.google-earth.kml+xml" class="gmnoprint"><img src="http://maps.google.com/mapfiles/ms/view_as_kml.png" width="16" height="16" alt="kml" /> <span>KML</span></a>
200    <a id="aLinkToThisPage" href="" class="gmnoprint"><img src="http://maps.google.com/mapfiles/bar_icon_link.gif" alt="&lt;-&gt;" width="16" height="16" /> <span>{'Link to this page'|@translate}</span></a>
201    <a id="aBlowup" href="" onclick="return PwgDataHandler.blowupUrl(this.href);" class="gmnoprint" title="{'show all pictures around this location'|@translate}">
202                        <img src="{$PLUGIN_ROOT_URL}/icons/pic_s.gif" alt="" title="{'show all pictures around this location'|@translate}" />
203                        <span>{'Show all'|@translate}</span>
204                </a>
205    <span class="gmnoprint">
206                        <form action="#" onsubmit="if (this.q.value!='' &amp;&amp; this.q.value!='{'Search a location...'|@translate|@escape:javascript}') searchLocation(this.q.value);return false;">
207                                <input type="text" size="32" name="q"
208                                        value="{'Search a location...'|@translate}"
209                                        onfocus="if (value=='{'Search a location...'|@translate|@escape:javascript}') value='';"
210                                        onblur="if (value=='') value='{'Search a location...'|@translate|@escape:javascript}'" />
211                                <input type="submit" value="{'Search'|@translate}"/>
212                        </form>
213                </span>
214  </div>
215  <div class="titlebar_title">
216    <a href="{$U_HOME}" title="{'return to homepage'|@translate}" class="gmnoprint">{'home'|@translate}</a>
217    <a href="{$U_HOME_MAP}" title="{'displays all images on a map'|@translate}"><img src="{$PLUGIN_ROOT_URL}/icons/map_sw.gif" width="32" height="17" alt="map"/></a>
218    {'Viewing'|@translate}: <a id="aPageUrl" href=""></a>
219  </div>
220</div>
221
222<div id="map"> </div>
223<script src="{$PLUGIN_ROOT_URL}/template/windows_13/javascripts/window.js" type="text/javascript" defer="defer"></script>
224</body>
225</html>
Note: See TracBrowser for help on using the repository browser.