Skip to content

Commit

Permalink
Table link to map (second try)
Browse files Browse the repository at this point in the history
  • Loading branch information
Johann Levesque committed Jan 24, 2013
1 parent 0bf63e0 commit 79660cb
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 105 deletions.
85 changes: 27 additions & 58 deletions demos/geomap/geomap-eng.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,66 +111,13 @@ <h1 id="wb-cont">Geomap</h1>

<div class="span-12">
<div class="span-4 row-start">
<<<<<<< HEAD
<div class="wet-boew-geomap span-4 border-all position scaleline layerswitcher" data-wet-boew="{ tables: ['sample1', 'sample2'], features:[ 'POINT (-123.1119, 49.2505)', 'POLYGON ((-120 54, -111 54, -111 50, -120 50, -120 54))', 'LINESTRING (-110 63, -105 60, -100 63)' ] }"></div>
=======
<div class="wet-boew-geomap span-4 border-all position scaleline layerswitcher" data-wet-boew="{ tables: ['cityE', 'cityW'], features:[ 'POINT (-123.1119, 49.2505)', 'POLYGON ((-120 54, -111 54, -111 50, -120 50, -120 54))', 'LINESTRING (-110 63, -105 60, -100 63)' ] }"></div>
>>>>>>> Table functionnalities
<div class="wet-boew-geomap span-4 border-all position scaleline layerswitcher" data-wet-boew="{ tables: ['cityE', 'cityW', 'bbox'], features:[ 'POINT (-123.1119, 49.2505)', 'POLYGON ((-120 54, -111 54, -111 50, -120 50, -120 54))', 'LINESTRING (-110 63, -105 60, -100 63)' ] }"></div>
</div>

<div class="span-4 row-end">
<<<<<<< HEAD
<table id="sample1" aria-label="Maritime Cities">
<caption>Maritime Cities</caption>
<thead>
<tr>
<th>Title</th>
<th>Description</th>
<th>Geometry</th>
</tr>
</thead>
<tbody>
<tr>
<td>St. John's</td>
<td>St. John's, the capital city of Newfoundland and Labrador, is the most easterly point in North America.</td>
<td class="feature">POINT (-52.7097, 47.5649)</td>
</tr>
<tr>
<td>Charlottetown</td>
<td>The City of Charlottetown is a flourishing community of over 32000 people located on the south shore of Prince Edward Island.</td>
<td class="feature">POINT (-63.1283, 46.2336)</td>
</tr>
</tbody>
</table>
<table id="sample2" aria-label="Search Results">
<caption>Search Results</caption>
<thead>
<tr>
<th>Title</th>
<th>Description</th>
<th>Geometry</th>
</tr>
</thead>
<tbody>
<tr>
<td class="title">Report on 2011 field activities and collection of ground thermal and active layer data in the Mackenzie Corridor completed under Northwest Territories science licence #14918</td>
<td class="description">This report presents a summary of field activities conducted in 2011 in the Mackenzie Corridor under N.W.T. Science Licence #14918. Air temperature, ground thermal and active layer data acquired from permafrost monitoring sites visited in 2011 throughout the corridor are provided in graphical and tabular format. This report will be distributed to community organizations and stakeholders in the study region to provide an update on field activities. The ground thermal and active layer data presented provide essential baseline information that can be utilized by stakeholders and others for various purposes such as land management activities, regulatory processes and design of northern infrastructure.</td>
<td class="geometry bbox">-136, 61, -118, 70</td>
</tr>
<tr>
<td class="title">Dinoflagellate cysts from upper cretaceous-lower tertiary sections, Bylot and Devon Islands, Arctic Archipelago</td>
<td class="description"> Abstract not available</td>
<td class="geometry bbox">-92.5, 72.75, -79, 75.5</td>
</tr>
</tbody>
</table>

</div>
=======
<div class="wet-boew-tabbedinterface">
<div class="wet-boew-tabbedinterface">
<ul class="tabs">
<li class="default"><a href="#tabs1_1">Tab 1</a></li>
<li><a href="#tabs1_2">Tab 2</a></li>
<li><a href="#tabs1_3">Tab 3</a></li>
</ul>
<div class="tabs-panel">
<div id="tabs1_1">
Expand Down Expand Up @@ -231,10 +178,32 @@ <h1 id="wb-cont">Geomap</h1>
</tbody>
</table>
</div>
</div>
<div id="tabs1_3">
<table id="bbox" aria-label="Search Results">
<caption>Search Results</caption>
<thead>
<tr>
<th>Title</th>
<th>Description</th>
<th>Geometry</th>
</tr>
</thead>
<tbody>
<tr>
<td class="title">Report on 2011 field activities and collection of ground thermal and active layer data in the Mackenzie Corridor completed under Northwest Territories science licence #14918</td>
<td class="description">This report presents a summary of field activities conducted in 2011 in the Mackenzie Corridor under N.W.T. Science Licence #14918. Air temperature, ground thermal and active layer data acquired from permafrost monitoring sites visited in 2011 throughout the corridor are provided in graphical and tabular format. This report will be distributed to community organizations and stakeholders in the study region to provide an update on field activities. The ground thermal and active layer data presented provide essential baseline information that can be utilized by stakeholders and others for various purposes such as land management activities, regulatory processes and design of northern infrastructure.</td>
<td class="geometry bbox">-136, 61, -118, 70</td>
</tr>
<tr>
<td class="title">Dinoflagellate cysts from upper cretaceous-lower tertiary sections, Bylot and Devon Islands, Arctic Archipelago</td>
<td class="description"> Abstract not available</td>
<td class="geometry bbox">-92.5, 72.75, -79, 75.5</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
>>>>>>> Table functionnalities
</div>
<div class="clear"></div><div class="clear"></div>

Expand Down
69 changes: 22 additions & 47 deletions src/js/workers/geomap.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,16 @@
map.removePopup(feature.popup);
feature.popup.destroy();
feature.popup = null;
},
},

getRandomColor: function() {
var letters = '0123456789ABCDEF'.split('');
var color = '#';
for (var i = 0; i < 6; i++) {
color += letters[Math.round(Math.random() * 15)];
}
return color;
},

getMap: function() {
return map;
Expand Down Expand Up @@ -443,8 +451,17 @@
// }
// }
// })
// });
// });

var randomColor = this.getRandomColor();

var my_style = new OpenLayers.StyleMap({
"default": new OpenLayers.Style(
{
strokeColor: "#990000",
fillColor: "#990000"
})
});

/*
* Add vector features
Expand Down Expand Up @@ -475,63 +492,21 @@
* TODO: turn this into a public function
*/

$.each(opts.tables, function(index, table) {

var randomColor = function() {
var letters = '0123456789ABCDEF'.split('');
var color = '#';
for (var i = 0; i < 6; i++) {
color += letters[Math.round(Math.random() * 15)];
}
return color;
};

var my_style = new OpenLayers.StyleMap({
"default": new OpenLayers.Style(
{
'strokeColor': randomColor,
'fillColor': randomColor,
'fillOpacity': 0.5,
'pointRadius': 5
})
});
$.each(opts.tables, function(index, table) {

var table_ = $("table#" + table);

<<<<<<< HEAD
var tableLayer = new OpenLayers.Layer.Vector($table.find('caption').text(), { styleMap: my_style });
=======
var tableLayer = new OpenLayers.Layer.Vector(table_.find('caption').text(), { /*styleMap: my_style*/ });
>>>>>>> Table functionnalities

var wktParser = new OpenLayers.Format.WKT({
'internalProjection': projMap,
'externalProjection': projLatLon
});
<<<<<<< HEAD
$.each($("table#" + table + ' td.geometry'), function(index, feature) {
if($(feature).hasClass('bbox')) {
bbox = $(feature).text().split(',');
wktFeature = "POLYGON(("
+ bbox[0] + " " + bbox[1] + ", "
+ bbox[0] + " " + bbox[3] + ", "
+ bbox[2] + " " + bbox[3] + ", "
+ bbox[2] + " " + bbox[1] + ", "
+ bbox[0] + " " + bbox[1] +
"))";
} else {
wktFeature = $(feature).text();
}
=======

$.each($("table#" + table + ' td.feature'), function(index, feature) {
>>>>>>> Table functionnalities
tableLayer.addFeatures([
wktParser.read(wktFeature)
]);
wktParser.read($(feature).text())
]);
});

map.addLayer(tableLayer);
Expand Down

0 comments on commit 79660cb

Please sign in to comment.