diff --git a/pandora_console/include/functions_gis.php b/pandora_console/include/functions_gis.php index b91c032ec3..075e46ceb4 100644 --- a/pandora_console/include/functions_gis.php +++ b/pandora_console/include/functions_gis.php @@ -512,9 +512,13 @@ function gis_get_map_conf($idMap) { } function get_good_con() { - $sql = 'SELECT * FROM tgis_map_connection WHERE id_tmap_connection = 2'; - - return db_get_all_rows_sql($sql); + + $good_map = db_get_row('tgis_map_connection', 'id_tmap_connection', 2); + // Try to open the default OpenStreetMap + if ($good_map !== false) { + return $good_map; + } + return db_get_row('tgis_map_connection', 'connection_type', 'OSM'); } function gis_get_map_connection($idMapConnection) { diff --git a/pandora_console/operation/gis_maps/public_console.php b/pandora_console/operation/gis_maps/public_console.php index 03ec5a5d5f..01a3af722a 100755 --- a/pandora_console/operation/gis_maps/public_console.php +++ b/pandora_console/operation/gis_maps/public_console.php @@ -56,6 +56,10 @@ $show_history = get_parameter ('show_history', 'n'); $map = db_get_row ('tgis_map', 'id_tgis_map', $idMap); $confMap = gis_get_map_conf($idMap); +// Default open map (used to overwrite unlicensed google map view) +$confMapDefault = get_good_con(); +$confMapUrlDefault = json_decode($confMapDefault['conection_data'], true)['url']; + $num_baselayer=0; // Initialy there is no Gmap base layer. $gmap_layer = false; @@ -71,11 +75,17 @@ if ($confMap !== false) { $baselayers[$num_baselayer]['url'] = $decodeJSON['url']; break; case 'Gmap': - $baselayers[$num_baselayer]['gmap_type'] = $decodeJSON['gmap_type']; - $baselayers[$num_baselayer]['gmap_key'] = $decodeJSON['gmap_key']; - $gmap_key = $decodeJSON['gmap_key']; - // Onece a Gmap base layer is found we mark it to import the API - $gmap_layer = true; + if (!isset($decodeJSON['gmap_key']) || empty($decodeJSON['gmap_key'])) { + // If there is not gmap_key, show the default view + $baselayers[$num_baselayer]['url'] = $confMapUrlDefault; + $baselayers[$num_baselayer]['typeBaseLayer'] = 'OSM'; + } else { + $baselayers[$num_baselayer]['gmap_type'] = $decodeJSON['gmap_type']; + $baselayers[$num_baselayer]['gmap_key'] = $decodeJSON['gmap_key']; + $gmap_key = $decodeJSON['gmap_key']; + // Once a Gmap base layer is found we mark it to import the API + $gmap_layer = true; + } break; case 'Static_Image': $baselayers[$num_baselayer]['url'] = $decodeJSON['url']; diff --git a/pandora_console/operation/gis_maps/render_view.php b/pandora_console/operation/gis_maps/render_view.php index cb3b7f0ad7..5d3996dd53 100644 --- a/pandora_console/operation/gis_maps/render_view.php +++ b/pandora_console/operation/gis_maps/render_view.php @@ -29,14 +29,9 @@ $show_history = get_parameter ('show_history', 'n'); $map = db_get_row ('tgis_map', 'id_tgis_map', $idMap); $confMap = gis_get_map_conf($idMap); -/* -------------------------------------------------- */ -/* I apply this change because open maps now are paid */ -/* --------------- Remove to go back ---------------- */ -/* -------------------------------------------------- */ -if ($confMap !== false) { /* ------------------------ */ - $confMap = get_good_con(); /* ------------------- */ -} /* ------------------------------------------------ */ -/* -------------------------------------------------- */ +// Default open map (used to overwrite unlicensed google map view) +$confMapDefault = get_good_con(); +$confMapUrlDefault = json_decode($confMapDefault['conection_data'], true)['url']; if (! check_acl ($config['id_user'], $map['group_id'], "MR") && ! check_acl ($config['id_user'], $map['group_id'], "MW") && ! check_acl ($config['id_user'], $map['group_id'], "MM")) { db_pandora_audit("ACL Violation", "Trying to access map builder"); @@ -59,11 +54,17 @@ if ($confMap !== false) { $baselayers[$num_baselayer]['url'] = $decodeJSON['url']; break; case 'Gmap': - $baselayers[$num_baselayer]['gmap_type'] = $decodeJSON['gmap_type']; - $baselayers[$num_baselayer]['gmap_key'] = $decodeJSON['gmap_key']; - $gmap_key = $decodeJSON['gmap_key']; - // Onece a Gmap base layer is found we mark it to import the API - $gmap_layer = true; + if (!isset($decodeJSON['gmap_key']) || empty($decodeJSON['gmap_key'])) { + // If there is not gmap_key, show the default view + $baselayers[$num_baselayer]['url'] = $confMapUrlDefault; + $baselayers[$num_baselayer]['typeBaseLayer'] = 'OSM'; + } else { + $baselayers[$num_baselayer]['gmap_type'] = $decodeJSON['gmap_type']; + $baselayers[$num_baselayer]['gmap_key'] = $decodeJSON['gmap_key']; + $gmap_key = $decodeJSON['gmap_key']; + // Once a Gmap base layer is found we mark it to import the API + $gmap_layer = true; + } break; case 'Static_Image': $baselayers[$num_baselayer]['url'] = $decodeJSON['url'];