Changeset 4797
- Timestamp:
- 11/14/08 09:03:54 (2 months ago)
- Files:
-
- googlemapmacro/dev/0.11 (modified) (1 prop)
- googlemapmacro/dev/0.11/tracgooglemap/htdocs/tracgooglemap.js (modified) (2 diffs)
- googlemapmacro/dev/0.11/tracgooglemap/macro.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
googlemapmacro/dev/0.11
- Property svn:mergeinfo set
googlemapmacro/dev/0.11/tracgooglemap/htdocs/tracgooglemap.js
r4714 r4797 55 55 // associated init function: 56 56 $("div.tracgooglemap") 57 .attr( 'id', function (index) {58 return 'tracgooglemap-' + index;59 })60 57 .each( function (index) { 61 58 var initfunc = tracgooglemapfuncs[index]; 62 59 if (initfunc) { 63 initfunc(this );60 initfunc(this, index); 64 61 } 65 62 }); … … 71 68 var key = $("link.google-key").attr('title'); 72 69 jQuery.getScript("http://www.google.com/jsapi?key=" + key, function () { 73 google.load("maps", "2 ", {"callback" : gmapiloaded})70 google.load("maps", "2.x", {"callback" : gmapiloaded}) 74 71 }); 75 72 } googlemapmacro/dev/0.11/tracgooglemap/macro.py
r4796 r4797 21 21 import re 22 22 23 COUNT = '_googlemapmacro_count' 24 23 25 _reWHITESPACES = re.compile(r'\s+') 24 26 _reCOMMA = re.compile(r',\s*') … … 41 43 //<![CDATA[ 42 44 43 TracGoogleMap( function (mapdiv ) {45 TracGoogleMap( function (mapdiv,index) { 44 46 var map = new GMap2(mapdiv, { 45 47 // size: new GSize(%(width)s, %(height)s), … … 64 66 } 65 67 %(markers_str)s 68 if ("%(directions)s") { 69 dirdiv = document.getElementById("tracgooglemap-directions-" + index); 70 gdir = new GDirections(map, dirdiv); 71 gdir.load("%(directions)s"); 72 } 66 73 }, "%(id)s" ); 67 74 … … 201 208 if len(largs) > 0: 202 209 arg = unicode(largs[0]) 210 if _reCOORDS.match(arg): 211 if not 'center' in kwargs: 212 kwargs['center'] = arg 213 else: 214 if not 'address' in kwargs: 215 kwargs['address'] = arg 216 if 'from' in kwargs and not 'address' kwargs and not 'center' in kwargs: 217 arg = unicode(kwargs['from']) 203 218 if _reCOORDS.match(arg): 204 219 if not 'center' in kwargs: … … 397 412 markers_str = ''.join( markers ) 398 413 414 # Get macro count from request object 415 req = formatter.req 416 count = getattr (req, COUNT, 0) 417 id = 'tracgooglemap-%s' % count 418 setattr (req, COUNT, count + 1) 419 420 # Canvas for this map 421 mapdiv = tag.div ( 422 "Google Map is loading ... (JavaScript enabled?)", 423 id=id, 424 style = "width: %s; height: %s;" % (width,height), 425 class_ = "tracgooglemap" 426 ) 427 428 if 'from' in kwargs and 'to' in kwargs: 429 directions = "from: %s to: %s" % (kwargs['from'],kwargs['to']) 430 mapnmore = tag.table( 431 tag.tr( 432 tag.td( 433 tag.div( "", 434 class_ = 'tracgooglemap-directions', 435 id = 'tracgooglemap-directions-%s' % count 436 ) 437 ), 438 tag.td( 439 mapdiv 440 ) 441 ), 442 class_ = 'tracgooglemaps' 443 ) 444 445 else: 446 directions = "" 447 mapnmore = mapdiv 448 399 449 # put everything in a tidy div 400 450 html = tag.div( … … 406 456 'type':type, 'width':width, 'height':height, 407 457 'types_str':types_str, 'controls_str':controls_str, 408 'markers_str':markers_str 458 'markers_str':markers_str, 'directions':directions, 409 459 }, 410 460 type = "text/javascript"), 411 # Canvas for this map 412 tag.div ( 413 "Google Map is loading ... (JavaScript enabled?)", 414 #id=id, 415 style = "width: %s; height: %s;" % (width,height), 416 class_ = "tracgooglemap" 417 ) 461 mapnmore 418 462 ], 419 463 class_ = "tracgooglemap-parent"
