mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-26 11:08:13 +00:00
make map tile layer configurable
This commit is contained in:
@@ -112,9 +112,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$aNominatimMapInit = [
|
$aNominatimMapInit = [
|
||||||
'zoom' => isset($_GET['zoom'])?htmlspecialchars($_GET['zoom']):NULL,
|
'zoom' => isset($_GET['zoom']) ? htmlspecialchars($_GET['zoom']) : CONST_Default_Zoom,
|
||||||
'lat' => isset($_GET['lat'] )?htmlspecialchars($_GET['lat']):NULL,
|
'lat' => isset($_GET['lat'] ) ? htmlspecialchars($_GET['lat'] ) : CONST_Default_Lat,
|
||||||
'lon' => isset($_GET['lon'] )?htmlspecialchars($_GET['lon']):NULL
|
'lon' => isset($_GET['lon'] ) ? htmlspecialchars($_GET['lon'] ) : CONST_Default_Lon,
|
||||||
|
'tile_url' => $sTileURL,
|
||||||
|
'tile_attribution' => $sTileAttribution
|
||||||
];
|
];
|
||||||
echo 'var nominatim_map_init = ' . json_encode($aNominatimMapInit, JSON_PRETTY_PRINT) . ';';
|
echo 'var nominatim_map_init = ' . json_encode($aNominatimMapInit, JSON_PRETTY_PRINT) . ';';
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
<link href="css/details.css" rel="stylesheet" type="text/css" />
|
<link href="css/details.css" rel="stylesheet" type="text/css" />
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<?php include(CONST_BasePath.'/lib/template/includes/html-top-navigation.php'); ?>
|
|
||||||
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
@@ -114,6 +113,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<body id="details-page">
|
<body id="details-page">
|
||||||
|
<?php include(CONST_BasePath.'/lib/template/includes/html-top-navigation.php'); ?>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
@@ -261,13 +261,23 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
<?php
|
||||||
|
|
||||||
var nominatim_result = {
|
$aNominatimMapInit = [
|
||||||
outlinestring: '<?php echo $aPointDetails['outlinestring'];?>',
|
'tile_url' => $sTileURL,
|
||||||
lon: <?php echo $aPointDetails['lon'];?>,
|
'tile_attribution' => $sTileAttribution
|
||||||
lat: <?php echo $aPointDetails['lat'];?>,
|
];
|
||||||
};
|
echo 'var nominatim_map_init = ' . json_encode($aNominatimMapInit, JSON_PRETTY_PRINT) . ';';
|
||||||
|
|
||||||
|
$aPlace = [
|
||||||
|
'outlinestring' => $aPointDetails['outlinestring'],
|
||||||
|
'lon' => $aPointDetails['lon'],
|
||||||
|
'lat' => $aPointDetails['lat'],
|
||||||
|
];
|
||||||
|
echo 'var nominatim_result = ' . json_encode($aPlace, JSON_PRETTY_PRINT) . ';';
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,9 @@
|
|||||||
$aNominatimMapInit = [
|
$aNominatimMapInit = [
|
||||||
'zoom' => $iZoom,
|
'zoom' => $iZoom,
|
||||||
'lat' => $fLat,
|
'lat' => $fLat,
|
||||||
'lon' => $fLon
|
'lon' => $fLon,
|
||||||
|
'tile_url' => $sTileURL,
|
||||||
|
'tile_attribution' => $sTileAttribution
|
||||||
];
|
];
|
||||||
echo 'var nominatim_map_init = ' . json_encode($aNominatimMapInit, JSON_PRETTY_PRINT) . ';';
|
echo 'var nominatim_map_init = ' . json_encode($aNominatimMapInit, JSON_PRETTY_PRINT) . ';';
|
||||||
|
|
||||||
|
|||||||
@@ -91,6 +91,8 @@
|
|||||||
@define('CONST_Default_Lat', 20.0);
|
@define('CONST_Default_Lat', 20.0);
|
||||||
@define('CONST_Default_Lon', 0.0);
|
@define('CONST_Default_Lon', 0.0);
|
||||||
@define('CONST_Default_Zoom', 2);
|
@define('CONST_Default_Zoom', 2);
|
||||||
|
@define('CONST_Map_Tile_URL', 'http://{s}.tile.osm.org/{z}/{x}/{y}.png');
|
||||||
|
@define('CONST_Map_Tile_Attribution', ''); // Set if tile source isn't osm.org
|
||||||
|
|
||||||
@define('CONST_Search_AreaPolygons_Enabled', true);
|
@define('CONST_Search_AreaPolygons_Enabled', true);
|
||||||
@define('CONST_Search_AreaPolygons', true);
|
@define('CONST_Search_AreaPolygons', true);
|
||||||
@@ -114,3 +116,5 @@
|
|||||||
@define('CONST_Log_File_Format', 'TODO'); // Currently hard coded
|
@define('CONST_Log_File_Format', 'TODO'); // Currently hard coded
|
||||||
@define('CONST_Log_File_SearchLog', '');
|
@define('CONST_Log_File_SearchLog', '');
|
||||||
@define('CONST_Log_File_ReverseLog', '');
|
@define('CONST_Log_File_ReverseLog', '');
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -127,4 +127,7 @@
|
|||||||
|
|
||||||
logEnd($oDB, $hLog, 1);
|
logEnd($oDB, $hLog, 1);
|
||||||
|
|
||||||
|
$sTileURL = CONST_Map_Tile_URL;
|
||||||
|
$sTileAttribution = CONST_Map_Tile_Attribution;
|
||||||
|
|
||||||
include(CONST_BasePath.'/lib/template/details-'.$sOutputFormat.'.php');
|
include(CONST_BasePath.'/lib/template/details-'.$sOutputFormat.'.php');
|
||||||
|
|||||||
@@ -10,30 +10,23 @@ jQuery(document).on('ready', function(){
|
|||||||
$('#q').focus();
|
$('#q').focus();
|
||||||
|
|
||||||
map = new L.map('map', {
|
map = new L.map('map', {
|
||||||
attributionControl: false, // moved to page footer
|
attributionControl: (nominatim_map_init.tile_attribution && nominatim_map_init.tile_attribution.length),
|
||||||
scrollWheelZoom: !L.Browser.touch,
|
scrollWheelZoom: !L.Browser.touch,
|
||||||
touchZoom: false
|
touchZoom: false
|
||||||
});
|
});
|
||||||
|
|
||||||
|
L.tileLayer(nominatim_map_init.tile_url, {
|
||||||
|
noWrap: true, // otherwise we end up with click coordinates like latitude -728
|
||||||
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
|
|
||||||
noWrap: true // otherwise we end up with click coordinates like latitude -728
|
|
||||||
// moved to footer
|
// moved to footer
|
||||||
// attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
attribution: (nominatim_map_init.tile_attribution || null ) //'© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
||||||
}).addTo(map);
|
}).addTo(map);
|
||||||
|
|
||||||
if ( nominatim_map_init.lat ){
|
map.setView([nominatim_map_init.lat, nominatim_map_init.lon], nominatim_map_init.zoom);
|
||||||
map.setView([nominatim_map_init.lat || 0, nominatim_map_init.lon], nominatim_map_init.zoom);
|
|
||||||
|
|
||||||
if ( is_reverse_search ){
|
if ( is_reverse_search ){
|
||||||
// not really a market, but the .circle changes radius once you zoom in/out
|
// We don't need a marker, but an L.circle instance changes radius once you zoom in/out
|
||||||
var cm = L.circleMarker([nominatim_map_init.lat,nominatim_map_init.lon], { radius: 5, weight: 2, fillColor: '#ff7800', color: 'red', opacity: 0.75, clickable: false});
|
var cm = L.circleMarker([nominatim_map_init.lat,nominatim_map_init.lon], { radius: 5, weight: 2, fillColor: '#ff7800', color: 'red', opacity: 0.75, clickable: false});
|
||||||
cm.addTo(map);
|
cm.addTo(map);
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
map.setView([0,0],2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -188,16 +181,18 @@ jQuery(document).on('ready', function(){
|
|||||||
map = new L.map('map', {
|
map = new L.map('map', {
|
||||||
// center: [nominatim_map_init.lat, nominatim_map_init.lon],
|
// center: [nominatim_map_init.lat, nominatim_map_init.lon],
|
||||||
// zoom: nominatim_map_init.zoom,
|
// zoom: nominatim_map_init.zoom,
|
||||||
attributionControl: false,
|
attributionControl: (nominatim_map_init.tile_attribution && nominatim_map_init.tile_attribution.length),
|
||||||
scrollWheelZoom: false,
|
scrollWheelZoom: false,
|
||||||
touchZoom: false,
|
touchZoom: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
|
|
||||||
|
L.tileLayer(nominatim_map_init.tile_url, {
|
||||||
// moved to footer
|
// moved to footer
|
||||||
// attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
attribution: (nominatim_map_init.tile_attribution || null ) //'© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
||||||
}).addTo(map);
|
}).addTo(map);
|
||||||
|
|
||||||
|
|
||||||
var layerGroup = new L.layerGroup().addTo(map);
|
var layerGroup = new L.layerGroup().addTo(map);
|
||||||
|
|
||||||
var circle = L.circleMarker([nominatim_result.lat,nominatim_result.lon], { radius: 10, weight: 2, fillColor: '#ff7800', color: 'blue', opacity: 0.75});
|
var circle = L.circleMarker([nominatim_result.lat,nominatim_result.lon], { radius: 10, weight: 2, fillColor: '#ff7800', color: 'blue', opacity: 0.75});
|
||||||
|
|||||||
@@ -76,4 +76,6 @@
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$sTileURL = CONST_Map_Tile_URL;
|
||||||
|
$sTileAttribution = CONST_Map_Tile_Attribution;
|
||||||
include(CONST_BasePath.'/lib/template/address-'.$sOutputFormat.'.php');
|
include(CONST_BasePath.'/lib/template/address-'.$sOutputFormat.'.php');
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
$fLat = CONST_Default_Lat;
|
$fLat = CONST_Default_Lat;
|
||||||
$fLon = CONST_Default_Lon;
|
$fLon = CONST_Default_Lon;
|
||||||
$iZoom = CONST_Default_Zoom;
|
$iZoom = CONST_Default_Zoom;
|
||||||
|
$sTileURL = CONST_Map_Tile_URL;
|
||||||
|
$sTileAttribution = CONST_Map_Tile_Attribution;
|
||||||
|
|
||||||
$oGeocode =& new Geocode($oDB);
|
$oGeocode =& new Geocode($oDB);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user