Skip to content

Commit

Permalink
Fix report list JS to allow adding all reports to the map.
Browse files Browse the repository at this point in the history
  • Loading branch information
rjmackay committed Feb 17, 2012
1 parent b60da7b commit a46fef1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
4 changes: 3 additions & 1 deletion hooks/analysis.php
Expand Up @@ -196,7 +196,9 @@ public function _save_analysis()

public function _save_analysis_js()
{
View::factory('analysis/report_list_js')->render(TRUE);
$this->template->js = View::factory('analysis/report_list_js');
$this->template->js->default_zoom = Kohana::config('settings.default_zoom');
$this->template->js->render(TRUE);
}
}

Expand Down
2 changes: 1 addition & 1 deletion views/analysis/report_list.php
Expand Up @@ -9,7 +9,7 @@
if ($analysis_incident->loaded)
{
echo "<li>";
echo "<a href=\"".url::site()."admin/reports/edit/".$a_id."\" target=\"_blank\">".$analysis_incident->incident_title."</a> <span class=\"analysis-mapme\">[<a href=\"javascript:analysisMapme('".$analysis_incident->location->longitude."','".$analysis_incident->location->latitude."')\">map</a>]</span>";
echo "<a href=\"".url::site()."admin/reports/edit/".$a_id."\" target=\"_blank\">".$analysis_incident->incident_title."</a> <span class=\"analysis-mapme\">[<a href=\"javascript:analysisMapme('".$analysis_incident->location->longitude."','".$analysis_incident->location->latitude."')\">add to map</a>]</span>";
echo "<input type=\"hidden\" name=\"a_id[]\" value=\"".$analysis_incident->id."\">";
echo "</li>";

Expand Down
23 changes: 18 additions & 5 deletions views/analysis/report_list_js.php
@@ -1,11 +1,24 @@
<script type="text/javascript" charset="utf-8">
function analysisMapme(lon, lat) {
function analysisMapme(newlon, newlat) {
var proj_4326 = new OpenLayers.Projection('EPSG:4326');
var proj_900913 = new OpenLayers.Projection('EPSG:900913');
var myPoint = new OpenLayers.LonLat(lon, lat);
m = new OpenLayers.Marker(myPoint.transform(proj_4326, proj_900913));
markers.clearMarkers();
markers.addMarker(m);

if (!isNaN(newlat) && !isNaN(newlon))
{
// Clear the map first
point = new OpenLayers.Geometry.Point(newlon, newlat);
OpenLayers.Projection.transform(point, proj_4326,proj_900913);

f = new OpenLayers.Feature.Vector(point);
vlayer.addFeatures(f);

// create a new lat/lon object
myPoint = new OpenLayers.LonLat(newlon, newlat);
myPoint.transform(proj_4326, map.getProjectionObject());

// display the map centered on a latitude and longitude
map.setCenter(myPoint, <?php echo $default_zoom; ?>);
}

// Update Form Value
$("#latitude").attr("value", lat);
Expand Down

0 comments on commit a46fef1

Please sign in to comment.