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() {
$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) {

View File

@ -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'];

View File

@ -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'];