source: products/qPloneGoogleMaps/tags/0.1.0/skins/qPloneGoogleMaps/view_js.py

Last change on this file was 1, checked in by myroslav, 17 years ago

Building directory structure

  • Property svn:eol-style set to native
File size: 1.3 KB
Line 
1## Script (Python) "view_js"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters= result=None
8##title=
9##
10
11map_center = (0,0)
12sMarker = ""
13if result:
14    map_center = result
15    sMarker = """
16var point = new GLatLng(parseFloat(%f), parseFloat(%f));
17var marker = new GMarker(point);
18map2.addOverlay(marker);""" % (map_center[0], map_center[1])
19
20return """
21<script src="http://maps.google.com/maps?file=api&v=2&key=%(key)s" type="text/javascript"></script>
22<script type="text/javascript">
23//<![CDATA[
24
25function onMapLoad() {
26    if (GBrowserIsCompatible()) {
27        var map2 = new GMap2(document.getElementById("mapView"));
28        map2.addControl(new GLargeMapControl());
29        map2.addControl(new GMapTypeControl());
30        map2.addControl(new GOverviewMapControl());
31        map2.setCenter(new GLatLng(%(lat)f, %(lng)f), 6, G_HYBRID_MAP);
32        %(marker)s
33    }
34    else window.alert("Google maps aren't compatible with current Browser.");
35}
36
37registerEventListener(window, 'load', onMapLoad)
38registerEventListener(window, 'unload', GUnload);
39
40//]]>
41</script> """ % {
42                 'key'      : context.getMapKey(),
43                  'lat'     : map_center[0],
44                  'lng'     : map_center[1],
45                  'marker'  : sMarker,
46                }
Note: See TracBrowser for help on using the repository browser.