Changeset 332


Ignore:
Timestamp:
07/28/10 01:47:29 (19 months ago)
Author:
takanori
Message:

simple polyline support

Location:
Products.ATGoogleMaps/trunk/Products/ATGoogleMaps
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • Products.ATGoogleMaps/trunk/Products/ATGoogleMaps/content/GPolyline.py

    r318 r332  
    3131    FloatField('opacity', 
    3232               default=1.0, 
     33               widget=StringWidget( 
     34                   label='Opacity', 
     35                   label_msgid='label_opacity', 
     36                   description_msgid='help_opacity', 
     37                   i18n_domain='googlemaps', 
     38                   size=8, 
     39                   ) 
    3340               ), 
    3441    IntegerField('weight', 
    35                  default=2, 
     42                 default=5, 
     43                 widget=StringWidget( 
     44                     label='Weight', 
     45                     label_msgid='label_weight', 
     46                     description_msgid='help_weight', 
     47                     i18n_domain='googlemaps', 
     48                     size=8, 
     49                     ) 
    3650                 ), 
     51    LinesField('coordinates', 
     52               widget=LinesWidget( 
     53                   label='Coordinates', 
     54                   label_msgid='label_path', 
     55                   description_msgid='help_path', 
     56                   i18n_domain='googlemaps', 
     57                   ) 
     58               ), 
    3759    ),) 
    3860gpolyline_schema = getattr(ATCTContent, 'schema', Schema(())).copy() + schema.copy() 
     
    5981        return latlng 
    6082 
     83    # return coordinates array string 
     84    def getCoordinatesArray(self): 
     85        coordinates_array = "[" 
     86        for coordinate in self.coordinates: 
     87             coordinates_array += "[%s]," % coordinate 
     88        coordinates_array = coordinates_array[:-1] + "]" 
     89        return coordinates_array 
     90 
    6191registerType(GPolyline, PROJECTNAME) 
  • Products.ATGoogleMaps/trunk/Products/ATGoogleMaps/profiles/default/types/GPolyline.xml

    r318 r332  
    1515 <property name="allowed_content_types" /> 
    1616 <property name="allow_discussion">False</property> 
    17  <property name="default_view">gpolyline_view</property> 
     17 <property name="default_view">base_view</property> 
    1818 <property name="view_methods"> 
    1919  <!-- <element value="banner_view"/> --> 
  • Products.ATGoogleMaps/trunk/Products/ATGoogleMaps/skins/ATGoogleMaps/atgooglemaps.js.dtml

    r298 r332  
    8585    return marker; 
    8686} 
     87 
     88function createPolyline(map, color, opacity, weight, title) { 
     89    var polyline = new google.maps.Polyline({ 
     90        strokeColor: color, 
     91        strokeOpacity: opacity, 
     92        strokeWeight: weight 
     93    }); 
     94 
     95    polyline.setMap(map); 
     96    return polyline; 
     97} 
     98 
     99function createPath(array) { 
     100    var mvcArray = new google.maps.MVCArray(); 
     101    for (var i = 0; i < array.length; i++) { 
     102        mvcArray.push(new google.maps.LatLng(array[i][0], array[i][1])); 
     103    } 
     104    return mvcArray; 
     105} 
  • Products.ATGoogleMaps/trunk/Products/ATGoogleMaps/skins/ATGoogleMaps/gmap.py

    r297 r332  
    11site_encoding =  context.plone_utils.getSiteEncoding() 
    22 
     3def add_polylines(js, items): 
     4    for index in range(len(items)): 
     5        polyline = items[index].getObject() 
     6        js.append('  var polyline_%d = createPolyline(map, "%s", %f, %d, "%s");' 
     7                  % (index, polyline.color, polyline.opacity, polyline.weight, polyline.title)) 
     8        js.append('  polyline_%d.setPath(createPath(%s));' % (index, polyline.getCoordinatesArray())) 
     9     
    310def add_markers(js, items): 
    411    for index in range(len(items)): 
     
    613        lat = marker.point['latitude'] 
    714        lng = marker.point['longitude'] 
    8         js.append('  var marker_%d = createMarker(map, %s, %s, "%d", "%s");' % (index, lat, lng, index, marker.title)) 
     15        js.append('  var marker_%d = createMarker(map, %s, %s, "%d", "%s");' 
     16                  % (index, lat, lng, index, marker.title)) 
    917 
    1018# create initialize method 
     
    1624               )) 
    1725 
    18     add_markers(js, context.getFolderContents()) 
     26    add_markers(js, context.getFolderContents({'portal_type': 'GMarker'})) 
     27    add_polylines(js, context.getFolderContents({'portal_type': 'GPolyline'})) 
    1928 
    2029    js.append('}') 
  • Products.ATGoogleMaps/trunk/Products/ATGoogleMaps/skins/ATGoogleMaps/gmap_view.pt

    r331 r332  
    3535    <!-- gmarker --> 
    3636    <div class="gmarkerBox" 
    37          tal:define="folderContents context/getFolderContents; 
     37         tal:define="folderContents python:context.getFolderContents({'portal_type': 'GMarker'}); 
    3838                     normalizeString nocall:context/@@plone/normalizeString;"> 
    3939      <ul class="gmarkerBlock"> 
  • Products.ATGoogleMaps/trunk/Products/ATGoogleMaps/skins/ATGoogleMaps/latlng_widget.pt

    r331 r332  
    1818      <tal:block tal:define="latitude value/latitude | string:35.7317; 
    1919                             longitude value/longitude | string:139.7278; 
    20                              zoom python:test(value, '14', '4'); 
    21                              Iterator python:modules['Products.CMFPlone'].IndexIterator; 
    22                  tabindex python:Iterator(mainSlot=False);"> 
     20                             zoom python:test(value, '14', '4');"> 
    2321 
    2422        <span tal:replace="structure context/latlng_map" /> 
     
    3230               value="" 
    3331               size="12" 
    34                tabindex="#" 
    3532               tal:attributes="name string:${fieldName}.latitude:record:ignore_empty; 
    3633                               value latitude; 
    3734                               size widget/size; 
    38                                maxlength widget/maxlength; 
    39                                tabindex tabindex/next;" 
     35                               maxlength widget/maxlength;" 
    4036               /> 
    4137         
     
    4844               value="" 
    4945               size="12" 
    50                tabindex="#" 
    5146               tal:attributes="name string:${fieldName}.longitude:record:ignore_empty; 
    5247                               value longitude; 
    5348                               size widget/size; 
    54                                maxlength widget/maxlength; 
    55                                tabindex tabindex/next;" 
     49                               maxlength widget/maxlength;" 
    5650               /> 
    5751 
     
    6761        <input class="standalone" type="button" id="s" 
    6862               value="Search" 
    69                tabindex="" 
    7063               onclick="geocode();" 
    7164               i18n:domain="plone" 
    7265               i18n:attributes="value label_search;" 
    73                tal:attributes="tabindex tabindex/next;" 
    7466               /> 
    7567 
    76         <div id="map_canvas" style="height: 300px; width: 400px;"> 
     68        <div id="map_canvas" style="height: 500px;"> 
    7769        <div id="crosshair"></div> 
    7870        </div> 
Note: See TracChangeset for help on using the changeset viewer.