1
0

Load GPS coordinates 1000 at a time instead of all at once.

This commit is contained in:
rWatcher 2012-06-27 20:19:46 -04:00
parent e38f3f3bc7
commit 38362c15b8
6 changed files with 323 additions and 127 deletions

View File

@ -18,6 +18,8 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class EXIF_GPS_Controller extends Controller {
public static $xml_records_limit = 1000;
public function item($item_id) {
// Make sure the context callback is set to album when linking to photos from map pages.
$item = ORM::factory("item", $item_id);
@ -26,7 +28,7 @@ class EXIF_GPS_Controller extends Controller {
url::redirect($item->abs_url());
}
public function xml($query_type, $query_id) {
public function xml($query_type, $query_id, $offset) {
// Generate an xml output of the photos to be mapped.
// $query_type can be either "album" or "user", $query_id is the id# of the album or user to map.
@ -42,13 +44,13 @@ class EXIF_GPS_Controller extends Controller {
->where("items.owner_id", "=", $query_id)
->viewable()
->order_by("exif_coordinates.latitude", "ASC")
->find_all();
->find_all(EXIF_GPS_Controller::$xml_records_limit, $offset);
} elseif ($query_type == "album") {
$items = ORM::factory("item", $query_id)
->join("exif_coordinates", "items.id", "exif_coordinates.item_id")
->viewable()
->order_by("exif_coordinates.latitude", "ASC")
->descendants();
->descendants(EXIF_GPS_Controller::$xml_records_limit, $offset);
}
$v = new View("exif_gps_coordinates_xml.html");
@ -67,14 +69,26 @@ class EXIF_GPS_Controller extends Controller {
throw new Kohana_404_Exception();
}
// Figure out what to display for the page title.
// Figure out what to display for the page title and how many items to display.
$map_title = "";
$items_count = 0;
if ($map_type == "album") {
$curr_album = ORM::factory("item")->where("id", "=", $type_id)->find_all();
$map_title = $curr_album[0]->title;
$items_count = ORM::factory("item", $type_id)
->join("exif_coordinates", "items.id", "exif_coordinates.item_id")
->viewable()
->order_by("exif_coordinates.latitude", "ASC")
->descendants_count();
} elseif ($map_type == "user") {
$curr_user = ORM::factory("user")->where("id", "=", $type_id)->find_all();
$map_title = $curr_user[0]->full_name . "'s " . t("Photos");
$items_count = ORM::factory("item")
->join("exif_coordinates", "items.id", "exif_coordinates.item_id")
->where("items.owner_id", "=", $type_id)
->viewable()
->order_by("exif_coordinates.latitude", "ASC")
->count_all();
}
// Set up breadcrumbs.
@ -105,6 +119,7 @@ class EXIF_GPS_Controller extends Controller {
} else {
$template->content->title = t("Map of") . " " . $map_title;
}
// Figure out default map type.
$int_map_type = module::get_var("exif_gps", "largemap_maptype");
if ($int_map_type == 0) $map_display_type = "ROADMAP";
@ -116,6 +131,7 @@ class EXIF_GPS_Controller extends Controller {
// These are used to set up the URL to the xml file.
$template->content->query_type = $map_type;
$template->content->query_id = $type_id;
$template->content->items_count = $items_count;
// Load in module preferences.
$template->content->google_map_key = module::get_var("exif_gps", "googlemap_api_key");

View File

@ -123,6 +123,7 @@ class exif_gps_block_Core {
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_count = 1;
} else {
$block->content = new View("exif_gps_static_sidebar.html");
if (module::get_var("exif_gps", "sidebar_maptype") == 0) $block->content->sidebar_map_type = "roadmap";
@ -134,12 +135,12 @@ class exif_gps_block_Core {
$block->content->longitude = $longitude;
} elseif (($theme->item()) && ($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)
$items_count = ORM::factory("item", $theme->item->id)
->join("exif_coordinates", "items.id", "exif_coordinates.item_id")
->viewable()
->order_by("exif_coordinates.latitude", "ASC")
->descendants(1);
if (count($items) > 0) {
->descendants_count();
if ($items_count > 0) {
$block = new Block();
$block->css_id = "g-exif-gps-location";
$block->title = t("Location");
@ -151,6 +152,7 @@ class exif_gps_block_Core {
$block->content->album_id = $theme->item->id;
$block->content->latitude = 0;
$block->content->longitude = 0;
$block->content->items_count = $items_count;
$block->content->google_map_key = module::get_var("exif_gps", "googlemap_api_key");
}
}

View File

@ -191,7 +191,7 @@ class exif_gps_event_Core {
->css_id("g-exif-gps-user-link"));
}
}
static function album_menu($menu, $theme) {
// Adds album and user map icons to album pages.
@ -248,12 +248,13 @@ class exif_gps_event_Core {
}
// If there's nothing to map, hide the map.
$items = ORM::factory("item")
->join("exif_coordinates", "items.id", "exif_coordinates.item_id")
->where("items.owner_id", "=", $data->user->id)
->viewable()
->find_all(1);
if (count($items) == 0) {
$items_count = ORM::factory("item")
->join("exif_coordinates", "items.id", "exif_coordinates.item_id")
->where("items.owner_id", "=", $data->user->id)
->viewable()
->order_by("exif_coordinates.latitude", "ASC")
->count_all();
if ($items_count == 0) {
return;
}
@ -266,6 +267,7 @@ class exif_gps_event_Core {
if ($int_map_type == 3) $map_type = "TERRAIN";
$v->map_type = $map_type;
$v->user_id = $data->user->id;
$v->items_count = $items_count;
$v->google_map_key = module::get_var("exif_gps", "googlemap_api_key");
$data->content[] = (object) array("title" => t("Photo Map"), "view" => $v);
}

View File

@ -8,9 +8,6 @@
print "google.load(\"maps\", \"3\", {other_params:\"sensor=false\"});";
}
?>
var google_zoom_hack = false;
var map = null;
<?
if (isset($album_id)) {
print " var album_id = " . $album_id . ";\n";
@ -19,14 +16,18 @@
}
?>
var google_zoom_hack = false;
var map = null;
$.ajaxSetup({
error: function(xhr, status, error) {
var status_text = document.getElementById('exif-gps-status');
status_text.innerHTML = "<font size=\"4\" color=\"white\"><strong>An AJAX error occured: " + status + "<br />\nError: " + error + "</strong></font>";
$('p.exif-gps-status').html("<font size=\"4\" color=\"white\"><strong>An AJAX error occured: " +
status + "<br />\nError: " + error + "</strong></font>");
}
});
function initialize() {
// Set up some initial variables and make a new map.
var myLatlng = new google.maps.LatLng(<?=$latitude; ?>,<?=$longitude; ?>);
var myOptions = {
zoom: 1,
@ -35,32 +36,25 @@
}
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var glatlngbounds = new google.maps.LatLngBounds( ); // This is so we can auto center the map.
// This is so we can auto-center and zoom the map.
// We will grow this each time a new set of coordinates is added onto the map
var glatlngbounds = new google.maps.LatLngBounds( );
// Set up some initial variables for looping through the coordinates in the xml files.
var map_markers = []; // Array of all unique coordinates.
var current_latlng = null; // Current coordinates. Used for merging duplicate coordinates together.
var item_counter = 0; // Current number of XML records that have been processed.
var int_max_items = <?= $items_count; ?>; // Total number of XML records to process.
var int_offset = 0; // Number of XML records to skip. Sent as a URL parameter when retrieving XML data.
var map_markers = [];
var current_latlng = null;
if (album_id > 0) {
jQuery.get("<?=url::abs_site("exif_gps/xml/album/{$album_id}"); ?>", {}, function(data) {
jQuery(data).find("marker").each(function() {
var xmlmarker = jQuery(this);
var latlng = new google.maps.LatLng(parseFloat(xmlmarker.attr("lat")),
parseFloat(xmlmarker.attr("lng")));
if (!latlng.equals(current_latlng)) {
current_latlng = latlng;
glatlngbounds.extend(latlng);
var marker = new google.maps.Marker({position: latlng});
map_markers.push(marker);
}
});
var mcOptions = { gridSize: <?= module::get_var("exif_gps", "markercluster_gridsize"); ?>, maxZoom: <?= module::get_var("exif_gps", "markercluster_maxzoom"); ?>};
var markerCluster = new MarkerClusterer(map, map_markers, mcOptions);
google_zoom_hack = true;
map.fitBounds(glatlngbounds);
document.getElementById('over_map').style.display = 'none';
});
// Retrieve the first batch of XML records.
// This function runs recursively until item_counter equals int_max_items.
// We're using recursion instead of a normal looping control, because normal
// loops would prevent the web browser from responding until the loop is finished.
get_xml();
} else {
// Only display a single marker.
var latlng = new google.maps.LatLng(<?=$latitude; ?>,<?=$longitude; ?>);
var marker = new google.maps.Marker({
position: latlng,
@ -70,6 +64,61 @@
document.getElementById('over_map').style.display = 'none';
}
function get_xml() {
// This function uses ajax requests to download and process a chunck of records, in XML format.
jQuery.ajax({
url: '<?=url::abs_site("exif_gps/xml/album/{$album_id}/"); ?>/' + int_offset,
success: function(data) {
jQuery(data).find("marker").each(function() {
// Loop through the retrieved records and add each one to the map.
// Process the current record.
item_counter++;
var xmlmarker = jQuery(this);
var latlng = new google.maps.LatLng(parseFloat(xmlmarker.attr("lat")),
parseFloat(xmlmarker.attr("lng")));
// Group multiple records with the same lat and lng coordinates together into
// the same marker.
if (!latlng.equals(current_latlng)) {
// ... then set up a new marker for this record.
current_latlng = latlng;
glatlngbounds.extend(latlng);
var marker = new google.maps.Marker({position: latlng});
map_markers.push(marker);
}
});
// Display a status message telling the user what percentage of records have been processed.
$('p.exif-gps-status').html("<font size=\"4\" color=\"white\"><strong><?= t("Loading..."); ?> " +
parseInt((item_counter / int_max_items) * 100) + "%</strong></font>" +
"<br /><br /><img src=\"<?= url::file("modules/exif_gps/images/exif_gps-loading-map-large.gif"); ?>\"" +
" style=\"vertical-align: middle;\"></img>");
// If item counter is less then max items, get the next batch of records.
// If item counter is equal to max items, then finish setting up the map and exit.
if (item_counter < int_max_items) {
int_offset += <?= EXIF_GPS_Controller::$xml_records_limit; ?>;
get_xml();
} else {
// Add the coordinates to the map, grouping clusters of similar coordinates together.
var mcOptions = { gridSize: <?= module::get_var("exif_gps", "markercluster_gridsize"); ?>, maxZoom: <?= module::get_var("exif_gps", "markercluster_maxzoom"); ?>};
var markerCluster = new MarkerClusterer(map, map_markers, mcOptions);
// Auto zoom and center the map around the coordinates.
// Set google_zoom_hack to true, to when the zoom changed function triggers
// we can re-zoom to the admin specified auto-zoom value, if necessary.
google_zoom_hack = true;
map.fitBounds(glatlngbounds);
// Hide the loading message and exit.
document.getElementById('over_map').style.display = 'none';
}
}
});
}
<? if (($max_autozoom = module::get_var("exif_gps", "googlemap_max_autozoom")) != "") : ?>
// If there is a maximum auto-zoom value, then set up an event to check the zoom
// level the first time it is changed, and adjust it if necessary.
@ -84,6 +133,23 @@
<? endif ?>
}
// Set up an info window at the specified coordinates
// to display the specified html.
markerClickFunction = function(str_thumb_html, latlng) {
return function(e) {
e.cancelBubble = true;
e.returnValue = false;
if (e.stopPropagation) {
e.stopPropagation();
e.preventDefault();
}
infoWindow.setContent(str_thumb_html);
infoWindow.setPosition(latlng);
infoWindow.open(map);
};
};
google.setOnLoadCallback(initialize);
</script>
@ -95,7 +161,7 @@
<div id="wrapper">
<div id="map_canvas" style="width:205px; height:214px"></div>
<div id="over_map" style="width:205px; height:214px">
<p id="exif-gps-status" style="text-align: center; display: table-cell; vertical-align: middle; width:205px; height:214px">
<p id="exif-gps-status" class="exif-gps-status" style="text-align: center; display: table-cell; vertical-align: middle; width:205px; height:214px">
<font size="4" color="white"><strong><?= t("Loading..."); ?></strong></font><br /><br />
<img src="<?= url::file("modules/exif_gps/images/exif_gps-loading-map-large.gif"); ?>" style="vertical-align: middle;"></img>
</p>

View File

@ -15,12 +15,13 @@
$.ajaxSetup({
error: function(xhr, status, error) {
var status_text = document.getElementById('exif-gps-status');
status_text.innerHTML = "<font size=\"6\" color=\"white\"><strong>An AJAX error occured: " + status + "<br />\nError: " + error + "</strong></font>";
$('p.exif-gps-status').html("<font size=\"6\" color=\"white\"><strong>An AJAX error occured: " +
status + "<br />\nError: " + error + "</strong></font>");
}
});
function initialize() {
// Set up some initial variables and make a new map.
var myLatlng = new google.maps.LatLng(0, 0);
var myOptions = {
zoom: 1,
@ -29,54 +30,106 @@
}
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var glatlngbounds = new google.maps.LatLngBounds( ); // This is so we can auto center the map.
// This is so we can auto-center and zoom the map.
// We will grow this each time a new set of coordinates is added onto the map
var glatlngbounds = new google.maps.LatLngBounds( );
// Initialize the infoWindow.
infoWindow = new google.maps.InfoWindow();
var map_markers = [];
var str_marker_html = "";
var current_latlng = null;
// Set up some initial variables for looping through the coordinates in the xml files.
var map_markers = []; // Array of all unique coordinates.
var str_marker_html = ""; // infoWindow HTML for the current set of coordinates.
var current_latlng = null; // Current coordinates. Used for merging duplicate coordinates together.
var item_counter = 0; // Current number of XML records that have been processed.
var int_max_items = <?= $items_count; ?>; // Total number of XML records to process.
var int_offset = 0; // Number of XML records to skip. Sent as a URL parameter when retrieving XML data.
jQuery.get("<?=url::abs_site("exif_gps/xml/{$query_type}/{$query_id}"); ?>", {}, function(data) {
jQuery(data).find("marker").each(function() {
var xmlmarker = jQuery(this);
var latlng = new google.maps.LatLng(parseFloat(xmlmarker.attr("lat")),
parseFloat(xmlmarker.attr("lng")));
// Retrieve the first batch of XML records.
// This function runs recursively until item_counter equals int_max_items.
// We're using recursion instead of a normal looping control, because normal
// loops would prevent the web browser from responding until the loop is finished.
get_xml();
if (!latlng.equals(current_latlng)) {
if (current_latlng != null) {
function get_xml() {
// This function uses ajax requests to download and process a chunck of records, in XML format.
jQuery.ajax({
url: '<?=url::abs_site("exif_gps/xml/{$query_type}/{$query_id}/"); ?>/' + int_offset,
success: function(data) {
jQuery(data).find("marker").each(function() {
// Loop through the retrieved records and add each one to the map.
// Process the current record.
item_counter++;
var xmlmarker = jQuery(this);
var latlng = new google.maps.LatLng(parseFloat(xmlmarker.attr("lat")),
parseFloat(xmlmarker.attr("lng")));
// Group multiple records with the same lat and lng coordinates together into
// the same marker and info window.
if (!latlng.equals(current_latlng)) {
// If the latest record has different coordinates then the previous record
// and this is not the first record (!=null) then set up the click function
// for the previous marker...
if (current_latlng != null) {
var fn = markerClickFunction(str_marker_html, current_latlng);
google.maps.event.addListener(map_markers[map_markers.length-1], 'click', fn);
}
// ... then set up a new marker for this record.
current_latlng = latlng;
str_marker_html = "";
glatlngbounds.extend(latlng);
var marker = new google.maps.Marker({position: latlng});
map_markers.push(marker);
}
// Convert any XML escape characters in this record to regular text.
var str_thumb_html = String(xmlmarker.attr("thumb"));
str_thumb_html = str_thumb_html.replace("&lt;", "<");
str_thumb_html = str_thumb_html.replace("&gt;", ">");
str_thumb_html = str_thumb_html.replace("&apos;", "\'");
str_thumb_html = str_thumb_html.replace("&quot;", "\"");
str_thumb_html = str_thumb_html.replace("&amp;", "&");
// Set up the HTML for this record and append it to the bottom of the info window.
str_thumb_html = "<div class=\"g-exif-gps-thumb\"><a href=\"" +
String(xmlmarker.attr("url")) + "\">" + str_thumb_html + "</a></div>";
str_marker_html += str_thumb_html;
});
// Display a status message telling the user what percentage of records have been processed.
$('p.exif-gps-status').html("<font size=\"6\" color=\"white\"><strong><?= t("Loading..."); ?> " +
parseInt((item_counter / int_max_items) * 100) + "%</strong></font>" +
"<br /><br /><img src=\"<?= url::file("modules/exif_gps/images/exif_gps-loading-map-large.gif"); ?>\"" +
" style=\"vertical-align: middle;\"></img>");
// If item counter is less then max items, get the next batch of records.
// If item counter is equal to max items, then finish setting up the map and exit.
if (item_counter < int_max_items) {
int_offset += <?= EXIF_GPS_Controller::$xml_records_limit; ?>;
get_xml();
} else {
// Set up the click function for the last coordinate.
var fn = markerClickFunction(str_marker_html, current_latlng);
google.maps.event.addListener(map_markers[map_markers.length-1], 'click', fn);
// Add the coordinates to the map, grouping clusters of similar coordinates together.
var mcOptions = { gridSize: <?= module::get_var("exif_gps", "markercluster_gridsize"); ?>, maxZoom: <?= module::get_var("exif_gps", "markercluster_maxzoom"); ?>};
var markerCluster = new MarkerClusterer(map, map_markers, mcOptions);
// Auto zoom and center the map around the coordinates.
// Set google_zoom_hack to true, to when the zoom changed function triggers
// we can re-zoom to the admin specified auto-zoom value, if necessary.
google_zoom_hack = true;
map.fitBounds(glatlngbounds);
// Hide the loading message and exit.
document.getElementById('over_map').style.display = 'none';
}
current_latlng = latlng;
str_marker_html = "";
glatlngbounds.extend(latlng);
var marker = new google.maps.Marker({position: latlng});
map_markers.push(marker);
}
var str_thumb_html = String(xmlmarker.attr("thumb"));
str_thumb_html = str_thumb_html.replace("&lt;", "<");
str_thumb_html = str_thumb_html.replace("&gt;", ">");
str_thumb_html = str_thumb_html.replace("&apos;", "\'");
str_thumb_html = str_thumb_html.replace("&quot;", "\"");
str_thumb_html = str_thumb_html.replace("&amp;", "&");
str_thumb_html = "<div class=\"g-exif-gps-thumb\"><a href=\"" +
String(xmlmarker.attr("url")) + "\">" + str_thumb_html + "</a></div>";
str_marker_html += str_thumb_html;
});
var fn = markerClickFunction(str_marker_html, current_latlng);
google.maps.event.addListener(map_markers[map_markers.length-1], 'click', fn);
var mcOptions = { gridSize: <?= module::get_var("exif_gps", "markercluster_gridsize"); ?>, maxZoom: <?= module::get_var("exif_gps", "markercluster_maxzoom"); ?>};
var markerCluster = new MarkerClusterer(map, map_markers, mcOptions);
google_zoom_hack = true;
map.fitBounds(glatlngbounds);
document.getElementById('over_map').style.display = 'none';
});
}
<? if (($max_autozoom = module::get_var("exif_gps", "googlemap_max_autozoom")) != "") : ?>
// If there is a maximum auto-zoom value, then set up an event to check the zoom
@ -92,6 +145,8 @@
<? endif ?>
}
// Set up an info window at the specified coordinates
// to display the specified html.
markerClickFunction = function(str_thumb_html, latlng) {
return function(e) {
e.cancelBubble = true;
@ -125,7 +180,7 @@
<div id="wrapper">
<div id="map_canvas" style="width:690px; height:480px;"></div>
<div id="over_map" style="width:690px; height:480px;">
<p id="exif-gps-status" style="text-align: center; display: table-cell; vertical-align: middle; width: 690px; height: 480px;">
<p id="exif-gps-status" class="exif-gps-status" style="text-align: center; display: table-cell; vertical-align: middle; width: 690px; height: 480px;">
<font size="6" color="white"><strong><?= t("Loading..."); ?></strong></font><br /><br />
<img src="<?= url::file("modules/exif_gps/images/exif_gps-loading-map-large.gif"); ?>" style="vertical-align: middle;"></img>
</p>

View File

@ -15,12 +15,13 @@
$.ajaxSetup({
error: function(xhr, status, error) {
var status_text = document.getElementById('exif-gps-status');
status_text.innerHTML = "<font size=\"6\" color=\"white\"><strong>An AJAX error occured: " + status + "<br />\nError: " + error + "</strong></font>";
$('p.exif-gps-status').html("<font size=\"6\" color=\"white\"><strong>An AJAX error occured: " +
status + "<br />\nError: " + error + "</strong></font>");
}
});
function initialize() {
// Set up some initial variables and make a new map.
var myLatlng = new google.maps.LatLng(0, 0);
var myOptions = {
zoom: 1,
@ -29,54 +30,106 @@
}
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var glatlngbounds = new google.maps.LatLngBounds( ); // This is so we can auto center the map.
// This is so we can auto-center and zoom the map.
// We will grow this each time a new set of coordinates is added onto the map
var glatlngbounds = new google.maps.LatLngBounds( );
// Initialize the infoWindow.
infoWindow = new google.maps.InfoWindow();
var map_markers = [];
var str_marker_html = "";
var current_latlng = null;
// Set up some initial variables for looping through the coordinates in the xml files.
var map_markers = []; // Array of all unique coordinates.
var str_marker_html = ""; // infoWindow HTML for the current set of coordinates.
var current_latlng = null; // Current coordinates. Used for merging duplicate coordinates together.
var item_counter = 0; // Current number of XML records that have been processed.
var int_max_items = <?= $items_count; ?>; // Total number of XML records to process.
var int_offset = 0; // Number of XML records to skip. Sent as a URL parameter when retrieving XML data.
jQuery.get("<?=url::abs_site("exif_gps/xml/user/{$user_id}"); ?>", {}, function(data) {
jQuery(data).find("marker").each(function() {
var xmlmarker = jQuery(this);
var latlng = new google.maps.LatLng(parseFloat(xmlmarker.attr("lat")),
parseFloat(xmlmarker.attr("lng")));
// Retrieve the first batch of XML records.
// This function runs recursively until item_counter equals int_max_items.
// We're using recursion instead of a normal looping control, because normal
// loops would prevent the web browser from responding until the loop is finished.
get_xml();
if (!latlng.equals(current_latlng)) {
if (current_latlng != null) {
function get_xml() {
// This function uses ajax requests to download and process a chunck of records, in XML format.
jQuery.ajax({
url: '<?=url::abs_site("exif_gps/xml/user/{$user_id}/"); ?>/' + int_offset,
success: function(data) {
jQuery(data).find("marker").each(function() {
// Loop through the retrieved records and add each one to the map.
// Process the current record.
item_counter++;
var xmlmarker = jQuery(this);
var latlng = new google.maps.LatLng(parseFloat(xmlmarker.attr("lat")),
parseFloat(xmlmarker.attr("lng")));
// Group multiple records with the same lat and lng coordinates together into
// the same marker and info window.
if (!latlng.equals(current_latlng)) {
// If the latest record has different coordinates then the previous record
// and this is not the first record (!=null) then set up the click function
// for the previous marker...
if (current_latlng != null) {
var fn = markerClickFunction(str_marker_html, current_latlng);
google.maps.event.addListener(map_markers[map_markers.length-1], 'click', fn);
}
// ... then set up a new marker for this record.
current_latlng = latlng;
str_marker_html = "";
glatlngbounds.extend(latlng);
var marker = new google.maps.Marker({position: latlng});
map_markers.push(marker);
}
// Convert any XML escape characters in this record to regular text.
var str_thumb_html = String(xmlmarker.attr("thumb"));
str_thumb_html = str_thumb_html.replace("&lt;", "<");
str_thumb_html = str_thumb_html.replace("&gt;", ">");
str_thumb_html = str_thumb_html.replace("&apos;", "\'");
str_thumb_html = str_thumb_html.replace("&quot;", "\"");
str_thumb_html = str_thumb_html.replace("&amp;", "&");
// Set up the HTML for this record and append it to the bottom of the info window.
str_thumb_html = "<div class=\"g-exif-gps-thumb\"><a href=\"" +
String(xmlmarker.attr("url")) + "\">" + str_thumb_html + "</a></div>";
str_marker_html += str_thumb_html;
});
// Display a status message telling the user what percentage of records have been processed.
$('p.exif-gps-status').html("<font size=\"6\" color=\"white\"><strong><?= t("Loading..."); ?> " +
parseInt((item_counter / int_max_items) * 100) + "%</strong></font>" +
"<br /><br /><img src=\"<?= url::file("modules/exif_gps/images/exif_gps-loading-map-large.gif"); ?>\"" +
" style=\"vertical-align: middle;\"></img>");
// If item counter is less then max items, get the next batch of records.
// If item counter is equal to max items, then finish setting up the map and exit.
if (item_counter < int_max_items) {
int_offset += <?= EXIF_GPS_Controller::$xml_records_limit; ?>;
get_xml();
} else {
// Set up the click function for the last coordinate.
var fn = markerClickFunction(str_marker_html, current_latlng);
google.maps.event.addListener(map_markers[map_markers.length-1], 'click', fn);
// Add the coordinates to the map, grouping clusters of similar coordinates together.
var mcOptions = { gridSize: <?= module::get_var("exif_gps", "markercluster_gridsize"); ?>, maxZoom: <?= module::get_var("exif_gps", "markercluster_maxzoom"); ?>};
var markerCluster = new MarkerClusterer(map, map_markers, mcOptions);
// Auto zoom and center the map around the coordinates.
// Set google_zoom_hack to true, to when the zoom changed function triggers
// we can re-zoom to the admin specified auto-zoom value, if necessary.
google_zoom_hack = true;
map.fitBounds(glatlngbounds);
// Hide the loading message and exit.
document.getElementById('over_map').style.display = 'none';
}
current_latlng = latlng;
str_marker_html = "";
glatlngbounds.extend(latlng);
var marker = new google.maps.Marker({position: latlng});
map_markers.push(marker);
}
var str_thumb_html = String(xmlmarker.attr("thumb"));
str_thumb_html = str_thumb_html.replace("&lt;", "<");
str_thumb_html = str_thumb_html.replace("&gt;", ">");
str_thumb_html = str_thumb_html.replace("&apos;", "\'");
str_thumb_html = str_thumb_html.replace("&quot;", "\"");
str_thumb_html = str_thumb_html.replace("&amp;", "&");
str_thumb_html = "<div class=\"g-exif-gps-thumb\"><a href=\"" +
String(xmlmarker.attr("url")) + "\">" + str_thumb_html + "</a></div>";
str_marker_html += str_thumb_html;
});
var fn = markerClickFunction(str_marker_html, current_latlng);
google.maps.event.addListener(map_markers[map_markers.length-1], 'click', fn);
var mcOptions = { gridSize: <?= module::get_var("exif_gps", "markercluster_gridsize"); ?>, maxZoom: <?= module::get_var("exif_gps", "markercluster_maxzoom"); ?>};
var markerCluster = new MarkerClusterer(map, map_markers, mcOptions);
google_zoom_hack = true;
map.fitBounds(glatlngbounds);
document.getElementById('over_map').style.display = 'none';
});
}
<? if (($max_autozoom = module::get_var("exif_gps", "googlemap_max_autozoom")) != "") : ?>
// If there is a maximum auto-zoom value, then set up an event to check the zoom
@ -92,6 +145,8 @@
<? endif ?>
}
// Set up an info window at the specified coordinates
// to display the specified html.
markerClickFunction = function(str_thumb_html, latlng) {
return function(e) {
e.cancelBubble = true;
@ -118,7 +173,7 @@
<div id="wrapper">
<div id="map_canvas" style="width:690px; height:480px;"></div>
<div id="over_map" style="width:690px; height:480px;">
<p id="exif-gps-status" style="text-align: center; display: table-cell; vertical-align: middle; width: 690px; height: 480px;">
<p id="exif-gps-status" class="exif-gps-status" style="text-align: center; display: table-cell; vertical-align: middle; width: 690px; height: 480px;">
<font size="6" color="white"><strong><?= t("Loading..."); ?></strong></font><br /><br />
<img src="<?= url::file("modules/exif_gps/images/exif_gps-loading-map-large.gif"); ?>" style="vertical-align: middle;"></img>
</p>