Added an album-mapping page.
This commit is contained in:
parent
9d8a667cf7
commit
d7ced770ac
71
modules/exif_gps/controllers/exif_gps.php
Normal file
71
modules/exif_gps/controllers/exif_gps.php
Normal file
@ -0,0 +1,71 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.");
|
||||
/**
|
||||
* Gallery - a web based photo album viewer and editor
|
||||
* Copyright (C) 2000-2010 Bharat Mediratta
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
class EXIF_GPS_Controller extends Controller {
|
||||
public function map($album_id) {
|
||||
// Map all items in the specified album.
|
||||
|
||||
// Generate an array of all items in the current album that have exif gps
|
||||
// coordinates and order by latitude (to group items w/ the same
|
||||
// coordinates together).
|
||||
$items = ORM::factory("item")
|
||||
->join("exif_coordinates", "items.id", "exif_coordinates.item_id")
|
||||
->where("items.parent_id", "=", $album_id)
|
||||
->order_by("exif_coordinates.latitude", "ASC")
|
||||
->find_all();
|
||||
|
||||
// Make a new page.
|
||||
$template = new Theme_View("page.html", "other", "TagsMap");
|
||||
$template->page_title = t("Gallery :: Map");
|
||||
$template->content = new View("exif_gps_map.html");
|
||||
|
||||
// Load in module preferences.
|
||||
$template->content->items = $items;
|
||||
$template->content->google_map_key = module::get_var("exif_gps", "googlemap_api_key");
|
||||
|
||||
// Display the page.
|
||||
print $template;
|
||||
|
||||
/*
|
||||
print "<br/>\n";
|
||||
print count($items);
|
||||
print "<br/>\n";
|
||||
print "<br/>\n";
|
||||
foreach ($items as $item) {
|
||||
print $item->name . "\t";
|
||||
$item_coordinates = ORM::factory("exif_coordinate")->where("item_id", "=", $item->id)->find();
|
||||
print $item_coordinates->latitude . "\t" . $item_coordinates->longitude;
|
||||
print "<br/>\n";
|
||||
}
|
||||
$template = new Theme_View("page.html", "other", "TagsMap");
|
||||
$template->page_title = t("Gallery :: Map");
|
||||
$template->content = new View("tagsmap_googlemap.html");
|
||||
|
||||
// Load in module preferences.
|
||||
$template->content->tags_gps = $tagsGPS;
|
||||
$template->content->google_map_key = module::get_var("tagsmap", "googlemap_api_key");
|
||||
$template->content->google_map_latitude = module::get_var("tagsmap", "googlemap_latitude");
|
||||
$template->content->google_map_longitude = module::get_var("tagsmap", "googlemap_longitude");
|
||||
$template->content->google_map_zoom = module::get_var("tagsmap", "googlemap_zoom");
|
||||
$template->content->google_map_type = module::get_var("tagsmap", "googlemap_type");
|
||||
|
||||
print $template;
|
||||
*/
|
||||
}
|
||||
}
|
@ -12,7 +12,7 @@
|
||||
var map = new google.maps.Map(document.getElementById("sidebar_map_canvas"), myOptions);
|
||||
var marker = new google.maps.Marker({
|
||||
position: latlng,
|
||||
map: map,
|
||||
map: map
|
||||
});
|
||||
}
|
||||
|
||||
|
65
modules/exif_gps/views/exif_gps_map.html.php
Normal file
65
modules/exif_gps/views/exif_gps_map.html.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||
<script type="text/javascript" src="http://www.google.com/jsapi?key=<?= module::get_var("exif_gps", "googlemap_api_key"); ?>"></script>
|
||||
<script type="text/javascript">
|
||||
google.load("maps", "3",{"other_params":"sensor=false"});
|
||||
function initialize() {
|
||||
var latlng = new google.maps.LatLng(0,0);
|
||||
var myOptions = {
|
||||
zoom: 1,
|
||||
center: latlng,
|
||||
mapTypeId: google.maps.MapTypeId.ROADMAP
|
||||
};
|
||||
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
|
||||
<? $counter = 1; ?>
|
||||
<? foreach ($items as $item) { ?>
|
||||
<? $item_coordinates = ORM::factory("exif_coordinate")->where("item_id", "=", $item->id)->find(); ?>
|
||||
<? if (!isset($currLat)) { ?>
|
||||
<? $currLat = $item_coordinates->latitude; ?>
|
||||
<? $currLong = $item_coordinates->longitude; ?>
|
||||
var marker<?=$counter; ?> = new google.maps.Marker({
|
||||
position: new google.maps.LatLng(<?=$item_coordinates->latitude; ?>,<?=$item_coordinates->longitude; ?>),
|
||||
map: map
|
||||
});
|
||||
<? $windowContent = "<div class=\\\"g-exif-gps-thumb\\\"><a href=\\\"" .
|
||||
$item->url() . "\\\">" .
|
||||
str_replace("\"", "\\\"", $item->thumb_img(array("class" => "g-exif-gps-thumbnail"))) .
|
||||
"</a></div>"; ?>
|
||||
<? } elseif (($currLat != $item_coordinates->latitude) && ($currLong != $item_coordinates->longitude)) { ?>
|
||||
var infowindow<?=$counter; ?> = new google.maps.InfoWindow({
|
||||
content: "<?=$windowContent; ?>",
|
||||
size: new google.maps.Size(50,50)
|
||||
});
|
||||
google.maps.event.addListener(marker<?=$counter; ?>, 'click', function() {
|
||||
infowindow<?=$counter; ?>.open(map,marker<?=$counter; ?>);
|
||||
});
|
||||
<? $counter++; ?>
|
||||
<? $currLat = $item_coordinates->latitude; ?>
|
||||
<? $currLong = $item_coordinates->longitude; ?>
|
||||
var marker<?=$counter; ?> = new google.maps.Marker({
|
||||
position: new google.maps.LatLng(<?=$item_coordinates->latitude; ?>,<?=$item_coordinates->longitude; ?>),
|
||||
map: map
|
||||
});
|
||||
<? $windowContent = "<div class=\\\"g-exif-gps-thumb\\\"><a href=\\\"" .
|
||||
$item->url() . "\\\">" .
|
||||
str_replace("\"", "\\\"", $item->thumb_img(array("class" => "g-exif-gps-thumbnail"))) .
|
||||
"</a></div>"; ?>
|
||||
<? } else { ?>
|
||||
<? $windowContent = $windowContent . " <div class=\\\"g-exif-gps-thumb\\\"><a href=\\\"" .
|
||||
$item->url() . "\\\">" .
|
||||
str_replace("\"", "\\\"", $item->thumb_img(array("class" => "g-exif-gps-thumbnail"))) .
|
||||
"</a></div>"; ?>
|
||||
<? } ?>
|
||||
<? } ?>
|
||||
var infowindow<?=$counter; ?> = new google.maps.InfoWindow({
|
||||
content: "<?=$windowContent; ?>",
|
||||
size: new google.maps.Size(50,50)
|
||||
});
|
||||
google.maps.event.addListener(marker<?=$counter; ?>, 'click', function() {
|
||||
infowindow<?=$counter; ?>.open(map,marker<?=$counter; ?>);
|
||||
});
|
||||
}
|
||||
|
||||
google.setOnLoadCallback(initialize);
|
||||
|
||||
</script>
|
||||
<div id="map_canvas" style="width:600px; height:480px;"></div>
|
Reference in New Issue
Block a user