diff --git a/db/zm_create.sql.in b/db/zm_create.sql.in
index af6a17182..cd4622df1 100644
--- a/db/zm_create.sql.in
+++ b/db/zm_create.sql.in
@@ -536,6 +536,8 @@ CREATE TABLE `Monitors` (
`ArchivedEventDiskSpace` bigint default NULL,
`ZoneCount` TINYINT NOT NULL DEFAULT 0,
`Refresh` int(10) unsigned default NULL,
+ `Latitude` DECIMAL(10,8),
+ `Longitude` DECIMAL(10,8),
PRIMARY KEY (`Id`)
) ENGINE=@ZM_MYSQL_ENGINE@;
diff --git a/db/zm_update-1.35.7.sql b/db/zm_update-1.35.7.sql
new file mode 100644
index 000000000..84c3dbb1e
--- /dev/null
+++ b/db/zm_update-1.35.7.sql
@@ -0,0 +1,23 @@
+SET @s = (SELECT IF(
+ (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
+ AND table_name = 'Monitors'
+ AND column_name = 'Latitude'
+ ) > 0,
+"SELECT 'Column Latitude already exists in Monitors'",
+"ALTER TABLE `Monitors` ADD `Latitude` DECIMAL(10,8) AFTER `Refresh`"
+));
+
+PREPARE stmt FROM @s;
+EXECUTE stmt;
+
+SET @s = (SELECT IF(
+ (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
+ AND table_name = 'Monitors'
+ AND column_name = 'Longitude'
+ ) > 0,
+"SELECT 'Column Longitude already exists in Monitors'",
+"ALTER TABLE `Monitors` ADD `Longitude` DECIMAL(10,8) AFTER `Latitude`"
+));
+
+PREPARE stmt FROM @s;
+EXECUTE stmt;
diff --git a/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in b/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in
index cf2b59c85..43fbcb457 100644
--- a/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in
+++ b/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in
@@ -479,6 +479,33 @@ our @options = (
type => $types{string},
category => 'system',
},
+ {
+ name => 'ZM_OPT_USE_GEOLOCATION',
+ description => 'Add geolocation features to ZoneMinder.',
+ help => 'Whether or not to enable Latitude/Longitude settings on Monitors and enable mapping options.',
+ type => $types{boolean},
+ category => 'system',
+ },
+ {
+ name => 'ZM_OPT_GEOLOCATION_TILE_PROVIDER',
+ description => 'Tile provider to use for maps.',
+ help => 'OpenStreetMaps does not itself provide the images to use in the map. There are many to choose from. Mapbox.com is one example that offers free tiles and has been tested during development of this feature.',
+ requires => [
+ {name=>'ZM_OPT_USE_GEOLOCATION', value=>'yes'}
+ ],
+ type => $types{string},
+ category => 'system',
+ },
+ {
+ name => 'ZM_OPT_GEOLOCATION_ACCESS_TOKEN',
+ description => 'Access Token for the tile provider used for maps.',
+ help => 'OpenStreetMaps does not itself provide the images to use in the map. There are many to choose from. Mapbox.com is one example that offers free tiles and has been tested during development of this feature. You must go to mapbox.com and sign up and get an access token and cutnpaste it here.',
+ requires => [
+ {name=>'ZM_OPT_USE_GEOLOCATION', value=>'yes'}
+ ],
+ type => $types{string},
+ category => 'system',
+ },
{
name => 'ZM_SYSTEM_SHUTDOWN',
default => 'true',
diff --git a/web/includes/Monitor.php b/web/includes/Monitor.php
index 65d1fc3ed..d1bd51509 100644
--- a/web/includes/Monitor.php
+++ b/web/includes/Monitor.php
@@ -129,6 +129,8 @@ class Monitor extends ZM_Object {
'Refresh' => null,
'DefaultCodec' => 'auto',
'GroupIds' => array('default'=>array(), 'do_not_update'=>1),
+ 'Latitude' => null,
+ 'Longitude' => null,
);
private $status_fields = array(
'Status' => null,
diff --git a/web/skins/classic/includes/functions.php b/web/skins/classic/includes/functions.php
index 203d3ffc2..d72b611bb 100644
--- a/web/skins/classic/includes/functions.php
+++ b/web/skins/classic/includes/functions.php
@@ -39,12 +39,29 @@ function xhtmlHeaders($file, $title) {
$baseViewCssPhpFile = getSkinFile('/css/base/views/'.$basename.'.css.php');
$viewCssPhpFile = getSkinFile('/css/'.$css.'/views/'.$basename.'.css.php');
- function output_link_if_exists($files) {
+ function output_link_if_exists($files, $cache_bust=true) {
global $skin;
$html = array();
foreach ( $files as $file ) {
if ( getSkinFile($file) ) {
+ if ( $cache_bust ) {
$html[] = '';
+ } else {
+ $html[] = '';
+ }
+ }
+ }
+ $html[] = ''; // So we ge a trailing \n
+ return implode(PHP_EOL, $html);
+ }
+ function output_script_if_exists($files, $cache_bust=true) {
+ global $skin;
+ $html = array();
+ foreach ( $files as $file ) {
+ if ( $cache_bust ) {
+ $html[] = '';
+ } else {
+ $html[] = '';
}
}
$html[] = ''; // So we ge a trailing \n
@@ -56,6 +73,9 @@ function xhtmlHeaders($file, $title) {
foreach ( $files as $file ) {
$html[] = '';
}
+ if ( ! count($html) ) {
+ ZM\Warning("No files found for $files");
+ }
$html[] = ''; // So we ge a trailing \n
return implode(PHP_EOL, $html);
}
@@ -109,6 +129,8 @@ if ( $css != 'base' )
echo output_link_if_exists(array('/css/base/views/control.css'));
if ( $css != 'base' )
echo output_link_if_exists(array('/css/'.$css.'/views/control.css'));
+ } else if ( $basename == 'monitor' ) {
+ echo output_link_if_exists(array('js/leaflet/leaflet.css'), false);
}
?>