Added option to map the entire contents of an album on the sidebar.
This commit is contained in:
parent
e520b6c42f
commit
de15c3f77b
@ -125,6 +125,25 @@ class exif_gps_block_Core {
|
|||||||
}
|
}
|
||||||
$block->content->latitude = $latitude;
|
$block->content->latitude = $latitude;
|
||||||
$block->content->longitude = $longitude;
|
$block->content->longitude = $longitude;
|
||||||
|
} elseif ($theme->item->is_album() && (module::get_var("exif_gps", "sidebar_mapformat") == 1)) {
|
||||||
|
// If coordinates were NOT found, and this is an album with a dynamic map, then map the contents of the album.
|
||||||
|
$items = ORM::factory("item", $theme->item->id)
|
||||||
|
->join("exif_coordinates", "items.id", "exif_coordinates.item_id")
|
||||||
|
->viewable()
|
||||||
|
->order_by("exif_coordinates.latitude", "ASC")
|
||||||
|
->descendants();
|
||||||
|
if (count($items) > 0) {
|
||||||
|
$block = new Block();
|
||||||
|
$block->css_id = "g-exif-gps-location";
|
||||||
|
$block->title = t("Location");
|
||||||
|
$block->content = new View("exif_gps_dynamic2_sidebar.html");
|
||||||
|
if (module::get_var("exif_gps", "sidebar_maptype") == 0) $block->content->sidebar_map_type = "ROADMAP";
|
||||||
|
if (module::get_var("exif_gps", "sidebar_maptype") == 1) $block->content->sidebar_map_type = "SATELLITE";
|
||||||
|
if (module::get_var("exif_gps", "sidebar_maptype") == 2) $block->content->sidebar_map_type = "HYBRID";
|
||||||
|
if (module::get_var("exif_gps", "sidebar_maptype") == 3) $block->content->sidebar_map_type = "TERRAIN";
|
||||||
|
$block->content->items = $items;
|
||||||
|
$block->content->google_map_key = module::get_var("exif_gps", "googlemap_api_key");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
43
modules/exif_gps/views/exif_gps_dynamic2_sidebar.html.php
Normal file
43
modules/exif_gps/views/exif_gps_dynamic2_sidebar.html.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?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.<?=$sidebar_map_type; ?>
|
||||||
|
};
|
||||||
|
var map = new google.maps.Map(document.getElementById("sidebar_map_canvas"), myOptions);
|
||||||
|
var glatlngbounds = new google.maps.LatLngBounds( ); // This is so we can auto center the map.
|
||||||
|
<? $counter = 1; ?>
|
||||||
|
<? foreach ($items as $item) { ?>
|
||||||
|
<? $item_coordinates = ORM::factory("exif_coordinate")->where("item_id", "=", $item->id)->find(); ?>
|
||||||
|
glatlngbounds.extend(new google.maps.LatLng(<?=$item_coordinates->latitude; ?>,<?=$item_coordinates->longitude; ?>));
|
||||||
|
<? 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
|
||||||
|
});
|
||||||
|
<? } elseif (($currLat != $item_coordinates->latitude) && ($currLong != $item_coordinates->longitude)) { ?>
|
||||||
|
<? $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
|
||||||
|
});
|
||||||
|
<? } else { ?>
|
||||||
|
<? } ?>
|
||||||
|
<? } ?>
|
||||||
|
map.fitBounds(glatlngbounds);
|
||||||
|
}
|
||||||
|
|
||||||
|
google.setOnLoadCallback(initialize);
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div id="sidebar_map_canvas" style="width:205px; height:214px"></div>
|
Reference in New Issue
Block a user