Changeset 4797

Show
Ignore:
Timestamp:
11/14/08 09:03:54 (2 months ago)
Author:
martin_s
Message:
0.11
Merged with 0.11_reqid branch.
Files:

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  
    5555        // associated init function: 
    5656        $("div.tracgooglemap") 
    57         .attr( 'id', function (index) { 
    58             return 'tracgooglemap-' + index; 
    59         }) 
    6057        .each( function (index) { 
    6158            var initfunc = tracgooglemapfuncs[index]; 
    6259            if (initfunc) { 
    63                 initfunc(this); 
     60                initfunc(this, index); 
    6461            } 
    6562        }); 
     
    7168        var key = $("link.google-key").attr('title'); 
    7269        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}) 
    7471        }); 
    7572    } 
  • googlemapmacro/dev/0.11/tracgooglemap/macro.py

    r4796 r4797  
    2121import re 
    2222 
     23COUNT = '_googlemapmacro_count' 
     24 
    2325_reWHITESPACES = re.compile(r'\s+') 
    2426_reCOMMA       = re.compile(r',\s*') 
     
    4143//<![CDATA[ 
    4244 
    43 TracGoogleMap( function (mapdiv) { 
     45TracGoogleMap( function (mapdiv,index) { 
    4446    var map = new GMap2(mapdiv, { 
    4547    //    size: new GSize(%(width)s, %(height)s), 
     
    6466    } 
    6567    %(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    } 
    6673}, "%(id)s" ); 
    6774 
     
    201208        if len(largs) > 0: 
    202209            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']) 
    203218            if _reCOORDS.match(arg): 
    204219                if not 'center' in kwargs: 
     
    397412            markers_str = ''.join( markers ) 
    398413 
     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 
    399449        # put everything in a tidy div 
    400450        html = tag.div( 
     
    406456                        'type':type, 'width':width, 'height':height, 
    407457                        'types_str':types_str, 'controls_str':controls_str, 
    408                         'markers_str':markers_str 
     458                        'markers_str':markers_str, 'directions':directions, 
    409459                        }, 
    410460                        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 
    418462                    ], 
    419463                class_ = "tracgooglemap-parent"