Modified GIS Maps to print OpenMaps on empty google license

This commit is contained in:
fermin831 2017-02-21 18:48:50 +01:00 committed by fermin
parent 2ccfedf9a5
commit f6816fa7f0
3 changed files with 36 additions and 21 deletions

View File

@ -512,9 +512,13 @@ function gis_get_map_conf($idMap) {
} }
function get_good_con() { function get_good_con() {
$sql = 'SELECT * FROM tgis_map_connection WHERE id_tmap_connection = 2';
$good_map = db_get_row('tgis_map_connection', 'id_tmap_connection', 2);
return db_get_all_rows_sql($sql); // 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) { function gis_get_map_connection($idMapConnection) {

View File

@ -56,6 +56,10 @@ $show_history = get_parameter ('show_history', 'n');
$map = db_get_row ('tgis_map', 'id_tgis_map', $idMap); $map = db_get_row ('tgis_map', 'id_tgis_map', $idMap);
$confMap = gis_get_map_conf($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; $num_baselayer=0;
// Initialy there is no Gmap base layer. // Initialy there is no Gmap base layer.
$gmap_layer = false; $gmap_layer = false;
@ -71,11 +75,17 @@ if ($confMap !== false) {
$baselayers[$num_baselayer]['url'] = $decodeJSON['url']; $baselayers[$num_baselayer]['url'] = $decodeJSON['url'];
break; break;
case 'Gmap': case 'Gmap':
$baselayers[$num_baselayer]['gmap_type'] = $decodeJSON['gmap_type']; if (!isset($decodeJSON['gmap_key']) || empty($decodeJSON['gmap_key'])) {
$baselayers[$num_baselayer]['gmap_key'] = $decodeJSON['gmap_key']; // If there is not gmap_key, show the default view
$gmap_key = $decodeJSON['gmap_key']; $baselayers[$num_baselayer]['url'] = $confMapUrlDefault;
// Onece a Gmap base layer is found we mark it to import the API $baselayers[$num_baselayer]['typeBaseLayer'] = 'OSM';
$gmap_layer = true; } 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; break;
case 'Static_Image': case 'Static_Image':
$baselayers[$num_baselayer]['url'] = $decodeJSON['url']; $baselayers[$num_baselayer]['url'] = $decodeJSON['url'];

View File

@ -29,14 +29,9 @@ $show_history = get_parameter ('show_history', 'n');
$map = db_get_row ('tgis_map', 'id_tgis_map', $idMap); $map = db_get_row ('tgis_map', 'id_tgis_map', $idMap);
$confMap = gis_get_map_conf($idMap); $confMap = gis_get_map_conf($idMap);
/* -------------------------------------------------- */ // Default open map (used to overwrite unlicensed google map view)
/* I apply this change because open maps now are paid */ $confMapDefault = get_good_con();
/* --------------- Remove to go back ---------------- */ $confMapUrlDefault = json_decode($confMapDefault['conection_data'], true)['url'];
/* -------------------------------------------------- */
if ($confMap !== false) { /* ------------------------ */
$confMap = get_good_con(); /* ------------------- */
} /* ------------------------------------------------ */
/* -------------------------------------------------- */
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")) { 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"); db_pandora_audit("ACL Violation", "Trying to access map builder");
@ -59,11 +54,17 @@ if ($confMap !== false) {
$baselayers[$num_baselayer]['url'] = $decodeJSON['url']; $baselayers[$num_baselayer]['url'] = $decodeJSON['url'];
break; break;
case 'Gmap': case 'Gmap':
$baselayers[$num_baselayer]['gmap_type'] = $decodeJSON['gmap_type']; if (!isset($decodeJSON['gmap_key']) || empty($decodeJSON['gmap_key'])) {
$baselayers[$num_baselayer]['gmap_key'] = $decodeJSON['gmap_key']; // If there is not gmap_key, show the default view
$gmap_key = $decodeJSON['gmap_key']; $baselayers[$num_baselayer]['url'] = $confMapUrlDefault;
// Onece a Gmap base layer is found we mark it to import the API $baselayers[$num_baselayer]['typeBaseLayer'] = 'OSM';
$gmap_layer = true; } 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; break;
case 'Static_Image': case 'Static_Image':
$baselayers[$num_baselayer]['url'] = $decodeJSON['url']; $baselayers[$num_baselayer]['url'] = $decodeJSON['url'];