Ticket #46: gmaps.patch

File gmaps.patch, 13.1 kB (added by ChristopherSchmidt, 3 years ago)

google maps template patch

  • site_index.tt

     
    77<div id="content"> 
    88[% INCLUDE navbar.tt %] 
    99<div id="maincontent"> 
     10    <div id="map" style="float:right;width: 400px; height: 400px"></div> 
     11    <script defer="defer" type="text/javascript"> 
     12    //<![CDATA[ 
     13     
     14    var map = new GMap(document.getElementById("map")); 
     15    map.addControl(new GSmallMapControl()); 
     16    map.centerAndZoom(new GPoint(-71.059270,42.358607), 6); 
     17 
     18[% i = 0 %] 
     19[%- FOREACH node = nodes %] 
     20[% i = i + 1 %] 
     21[% metadata = node.node_data.metadata %] 
     22[% IF metadata.latitude.list.first AND metadata.longitude.list.first %] 
     23    var point[% i %] = new GPoint([% metadata.longitude.list.first %], [% metadata.latitude.list.first %]);  
     24    var marker[% i %] = new GMarker(point[% i %],baseIcon); 
     25    var htmlString[% i %] = "<a href=\"?[% node.param %]\">[% node.name %]</a><br />[% metadata.address.list.first %]<br />[% metadata.city.list.first %]"; 
     26    GEvent.addListener(marker[% i %], "click", function() {  
     27        marker[% i %].openInfoWindowHtml(htmlString[% i %]);  
     28        });  
     29    map.addOverlay(marker[% i %]);  
     30     
     31 
     32 
     33  [%- END -%] 
     34[%- END -%] 
     35    //]]> 
     36    </script> 
    1037<h2>Node List 
    1138  [%- IF criterion -%] 
    1239    [%- IF criterion.url -%] 
     
    2047  [%- END -%] 
    2148</h2> 
    2249<ol> 
     50[% i = 0 %] 
    2351  [% FOREACH node = nodes %] 
     52[% metadata = node.node_data.metadata %] 
     53[% i = i + 1 %] 
    2454     <li><a href="[% cgi_url %]?[% node.param %]">[% node.name %]</a> 
     55[% IF metadata.latitude.list.first AND metadata.longitude.list.first %] <small>(<a href='#' onclick="marker[% i %].openInfoWindowHtml(htmlString[% i %]); return false;">show on map</a>)</small> [% END %] 
    2556         [% IF node.distance %]([% node.distance %] metres away)[% END %] 
    2657     </li> 
    2758  [% END %] 
  • map_index.tt

     
     1[% USE CGI %] 
     2[% INCLUDE header.tt %] 
     3[% INCLUDE banner.tt %] 
     4<div id="content"> 
     5<a href="" id="permalink">Link to this Page</a> | <a href="" onclick="showTowns(); return false;">Show Town Boundaries</a> 
     6<ul style="height:400px; overflow:auto;float:right; width:30%;"> 
     7[% i = 0 %] 
     8[%- FOREACH node = nodes %] 
     9[% metadata = node.node_data.metadata %] 
     10[% i = i + 1 %] 
     11[% IF metadata.latitude.list.first AND metadata.longitude.list.first %] 
     12<li><a href='#' onclick="marker[% i %].openInfoWindowHtml(htmlString[% i %]); return false;">[% node.name %]</a>[% IF metadata.city.list.first %], [% metadata.city.list.first %][% END %]</li> 
     13[%- END -%] 
     14[%- END -%] 
     15</ul> 
     16<table width="100%" height="100%"> 
     17<tr> <td> 
     18    <div id="map" style=" width: 65%; height: 450px"></div> 
     19</td></tr></table> 
     20<script defer="defer" type="text/javascript"> 
     21    //<![CDATA[ 
     22    var map = new GMap(document.getElementById("map")); 
     23    map.addControl(new GLargeMapControl()); 
     24    map.addControl(new GMapTypeControl()); 
     25    map.centerAndZoom(new GPoint([% IF long %][% long %][% ELSE %]-71.059270[% END %],[% IF lat %][% lat %][% ELSE %]42.358607[% END %]), [% IF zoom %][% zoom %][% ELSE %]5[% END %]); 
     26 
     27[% i = 0 %] 
     28[%- FOREACH node = nodes %] 
     29[% i = i + 1 %] 
     30[% metadata = node.node_data.metadata %] 
     31[% IF metadata.latitude.list.first AND metadata.longitude.list.first %] 
     32    var point[% i %] = new GPoint([% metadata.longitude.list.first %], [% metadata.latitude.list.first %]);  
     33    var marker[% i %] = new GMarker(point[% i %],baseIcon); 
     34    var htmlString[% i %] = "<a href=\"?[% node.param %]\">[% node.name %]</a>&nbsp;<a style='text-decoration:none;' href=\"?id=[% node.param %];action=edit\">(edit)</a><br />[% metadata.address.list.first %]<br />[% metadata.city.list.first %]"; 
     35    GEvent.addListener(marker[% i %], "click", function() {  
     36        marker[% i %].openInfoWindowHtml(htmlString[% i %]);  
     37        });  
     38    map.addOverlay(marker[% i %]);  
     39  [%- END -%] 
     40[%- END -%] 
     41    function map_recenter() { 
     42        var center = map.getCenterLatLng(); 
     43        var link = document.getElementById('permalink'); 
     44        var zoom = map.getZoomLevel(); 
     45        link.href = "?action=index;format=map&long="+center.x+"&lat="+center.y+"&zoom="+zoom; 
     46    } 
     47    GEvent.addListener(map, "moveend", map_recenter ); 
     48    //]]> 
     49    </script> 
     50</div> 
     51 
     52[% INCLUDE footer.tt %] 
  • search.tt

     
    2222    <a href="[% ss_info_url %]">information page</a> for help and more details. 
    2323  </small></p> 
    2424 
    25   <form method="get" action="search.cgi"> 
    26     <table border="1"> 
     25  <form method="get" action="supersearch.cgi"> 
     26    <table> 
    2727      <tr> 
    2828         <th> 
    2929           <label for="search_upper">Pages containing text:</label> 
     
    3232           <input type="text" name="search" value="[% IF search_terms %][% search_terms %][% END %]" size="50" maxlength="80" id="search_upper" /> 
    3333         </td> 
    3434       </tr> 
    35       <tr> 
    36         <th>Location:</th> 
     35      <tr valign="top"> 
     36        <th><p>Location:</p></th> 
    3737        <td> 
    3838        [% IF coord_field_1 != 'latitude' %] 
    3939          <p> 
     
    5656      </tr> 
    5757    </table> 
    5858  </form> 
    59  
     59  <script>locations = []; </script> 
     60  [% IF latitude and longitude %] 
     61    <div id="map" class='searchmap'></div> 
     62    <script defer='defer'> 
     63    var map = new GMap(document.getElementById("map")); 
     64map.addOverlay(orangeLine); 
     65map.addOverlay(redLine); 
     66map.addOverlay(redLineM); 
     67map.addOverlay(blueLine); 
     68map.addOverlay(greenLine); 
     69map.addOverlay(greenLineE); 
     70map.addOverlay(greenLineB); 
     71map.addOverlay(greenLineC); 
     72map.addOverlay(greenLineD); 
     73    map.addControl(new GSmallMapControl()); 
     74    map.centerAndZoom(new GPoint([% longitude %], [% latitude %]), 3); 
     75    </script> 
     76    [% END %] 
    6077  [% IF search_terms OR dist %] 
    6178 
    6279    <hr /> 
    63  
    6480    [% IF results.size %] 
    6581 
    6682      <ol start="[% first_num %]"> 
    6783        [% FOREACH result = results %] 
    6884          <li> 
    69             <a href="[% result.url %]"><b>[% result.name %]</b></a> (score: [% result.score %]) 
     85            <a href="[% result.url %]"><b>[% result.name %]</b></a>[% IF result.score %] (score: [% result.score %])[% END %] 
    7086            [% IF result.distance %] 
    7187              ([% result.distance %] metres away) 
    7288            [% END %][% IF result.summary %] 
    7389            <div class="hit_summary"> 
    7490            [% result.summary %] 
    75             </div>[% END %] 
     91            </div>[% END %] [% IF result.lat AND result.long %]<script> locations.push({'long':[% result.long %], 'lat':[% result.lat %], 'name': "[% result.name %]", 'score': '[% result.score %]', 'distance': '[% result.distance %]', 'summary': "[% result.summary %]"}); </script> [% END %] 
    7692          </li> 
    7793        [% END %] 
    7894      </ol> 
    7995 
     96  [% IF latitude and longitude %] 
     97    <script defer='defer'> 
     98        var markers = []; 
     99        function addEv(myloc,l) { 
     100            GEvent.addListener(markers[myloc], "click", function() { 
     101                html = '<div style="width:15em;">'; 
     102                html += l.name; 
     103                if (l.score) { 
     104                    html += ' (l.score)'; 
     105                } 
     106                if (l.summary) { 
     107                    html += '<br />'+l.summary; 
     108                } 
     109                if (l.distance) { 
     110                    html += '<br />'+l.distance+' meters away.'; 
     111                } 
     112                html += '</div>'; 
     113                markers[myloc].openInfoWindowHtml(html); 
     114            }); 
     115        } 
     116        for (var myLocation in locations) { 
     117            var l = locations[myLocation]; 
     118            markers[myLocation] = new GMarker(new GPoint(l['long'], l['lat']), baseIcon); 
     119            addEv(myLocation,l) 
     120            map.addOverlay(markers[myLocation]); 
     121        } 
     122    </script> 
     123  [% END %] 
    80124      <p> 
    81125      Matches [% first_num %] - [% last_num %] of [% total_num %].  
    82       [% IF (first_num > 20) %] 
    83         <a href="search.cgi?search=[% search_terms %]&next=[% first_num - 21 %]">Previous 20 results</a>  
     126      [% IF (first_num > page_size) %] 
     127        <a href="supersearch.cgi?search=[% search_terms %]&next=[% first_num - (page_size + 1) %]">Previous [%- page_size -%] results</a>  
    84128      [% END %]  
    85       [% IF ((first_num > 20) and next_page_startpos) %] 
     129      [% IF ((first_num > page_size) and next_page_startpos) %] 
    86130      /  
    87131      [% END %] 
    88132      [% IF next_page_startpos %] 
    89         <a href="search.cgi?search=[% search_terms %];[% dist_field %]=[% dist %];[% coord_field_1 %]=[% coord_field_1_value %];[% coord_field_2 %]=[% coord_field_2_value %];next=[% next_page_startpos %]">Next  
    90         [% IF ((total_num - last_num >= 20)) %] 
    91           20 
     133        <a href="supersearch.cgi?search=[% search_terms %];[% dist_field %]=[% dist %];[% coord_field_1 %]=[% coord_field_1_value %];[% coord_field_2 %]=[% coord_field_2_value %];next=[% next_page_startpos %]">Next  
     134        [% IF ((total_num - last_num >= page_size)) %] 
     135          [%- page_size -%] 
    92136        [% ELSE %] 
    93137          [% total_num - last_num %] 
    94138        [% END %] 
     
    100144      <h2>No Items Matched</h2> 
    101145    [% END %]   
    102146 
    103   <form method="get" action="search.cgi"> 
     147  <form method="get" action="supersearch.cgi"> 
    104148    <label for="search_lower">Search:</label>  
    105149    <input type="text" name="search" id="search_lower" value="[% search_terms %]" size="50" maxlength="80" value="Search text" onclick="this.value=''" /> 
    106150    <input type="submit" name="go" class="form_button" value="Go" /> 
  • node.tt

     
    77[% IF oldid %] 
    88<div id="redirect_message">(redirected from <a href="[% full_cgi_url %]?id=[% oldid %];redirect=0">[% oldid.replace('_', ' ') %]</a>)</div> 
    99[% END %] 
     10[% IF latitude AND longitude %] 
    1011 
     12    <div id="map" style="float:right; width: 300px; height: 200px"></div> 
     13    <script defer="defer" type="text/javascript"> 
     14    //<![CDATA[ 
     15  
     16    var map = new GMap(document.getElementById("map")); 
     17    map.addControl(new GSmallMapControl()); 
     18    map.centerAndZoom(new GPoint([% longitude %], [% latitude %]), 3); 
     19    var point0 = new GPoint([% longitude %], [% latitude %]);  
     20    var marker0 = new GMarker(point0,baseIcon); 
     21    GEvent.addListener(marker0, "click", function() {  
     22        marker0.openInfoWindowHtml("[% node_name %]");  
     23        });  
     24    map.addOverlay(marker0);  
     25     
     26    //]]> 
     27    </script> 
     28[% END %] 
     29 
    1130[% IF current %] 
    1231  [% IF backlinks_in_title AND is_indexable_node %] 
    1332    <h2 class="node_name"><a href="[% cgi_url %]?action=index;index_type=[% CGI.escape(index_type) %];index_value=[% CGI.escape(index_value) %]">[% node_name %]</a></h2> 
     
    2342  </h2> 
    2443[% END %] 
    2544[% IF not (content || coord_field_1_value || coord_field_2_value || latitude || longitude) %] 
    26 We don't have a node called "[% node_param %]". Would you like to <a href="[% full_cgi_url %]?action=edit;id=[% node_param %]">create it</a>? 
     45We don't have a node called "[% node_name %]". Would you like to <a href="/?action=edit;id=[% node_param %]">make it</a>? 
    2746[% ELSE %] 
    2847[% INCLUDE display_metadata.tt %] 
    2948 
     
    3453[% TRY %] 
    3554  [% INCLUDE custom_node.tt %] 
    3655[% CATCH %] 
    37 [% END %] 
    3856                           
    3957[% IF coord_field_1_value AND coord_field_2_value %] 
    4058  <br clear="all" /> 
    4159  <div id="find_within_distance"> 
    42     <form action="search.cgi"> 
     60    <form action="supersearch.cgi"> 
    4361      <label for="distance">Find all things within</label> 
    4462      <select name="[% dist_field %]" id="distance"> 
    4563        <option value="500">500 metres</option> 
     
    103121[% END %] 
    104122</div> 
    105123[% END %] 
     124[% END %] 
    106125</div> 
    107126[% INCLUDE footer.tt %] 
  • header.tt

     
    1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
    2  "http://www.w3.org/TR/html4/loose.dtd"> 
    3 <html lang="[% language %]"> 
     1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
     2        "http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-transitional.dtd"> 
     3        <html xmlns="http://www.w3.org/1999/xhtml"  lang="[% language %]" xmlns:v="urn:schemas-microsoft-com:vml"> 
    44<head> 
     5    <style type="text/css"> 
     6    v\:* { 
     7      behavior:url(#default#VML); 
     8    } 
     9    </style> 
    510  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    611  [% IF page_title %] 
    712    <title>[% page_title %]</title> 
     
    2833  [% IF deter_robots %] 
    2934    <meta name="robots" content="noindex,nofollow" /> 
    3035  [% END %] 
     36  <script src="http://maps.google.com/maps?file=api&amp;v=1&amp;key=[% gmaps_api_key %]" type="text/javascript"></script> 
    3137</head> 
    3238<body> 
     39    <script defer="defer" type="text/javascript"> 
     40    //<![CDATA[ 
     41     
     42    var baseIcon = new GIcon();  
     43    baseIcon.image = "http://www.google.com/mapfiles/marker.png";  
     44    baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";  
     45    baseIcon.iconSize = new GSize(10, 17);  
     46    baseIcon.shadowSize = new GSize(20, 17);  
     47    baseIcon.iconAnchor = new GPoint(5, 17);  
     48    baseIcon.infoWindowAnchor = new GPoint(9, 2);  
     49    baseIcon.infoShadowAnchor = new GPoint(9, 12);  
     50 
     51    
     52    //]]> 
     53    </script>