Skip to content

Commit 5555e35

Browse files
authored
Merge pull request #178 from fg193/master
fix reverse geocoding service (#164)
2 parents 7004e4d + 45137c5 commit 5555e35

2 files changed

Lines changed: 10 additions & 11 deletions

File tree

admin/admin_tag.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,15 @@
110110
$infos = array();
111111
foreach ($images as $image)
112112
{
113-
// Fech reverse location from API
113+
// Fetch reverse location from API
114114
// http://wiki.openstreetmap.org/wiki/Nominatim
115115
// https://nominatim.openstreetmap.org/reverse?format=xml&lat=51.082333&lon=10.366229&zoom=12
116116
// https://open.mapquestapi.com/nominatim/v1/reverse.php?format=xml&lat=48.858366666667&lon=2.2942166666667&zoom=12
117-
//$osm_url = "https://nominatim.openstreetmap.org/reverse?format=json&addressdetails=1&zoom=12&lat=". $image['latitude'] ."&lon=". $image['longitude'];
117+
$osm_url = "https://nominatim.openstreetmap.org/reverse?format=json&addressdetails=1&zoom=12&lat=". $image['latitude'] ."&lon=". $image['longitude'] ."&accept-language=". $sync_options['language'];
118118
// As of Sept 2015 require a API KEY
119119
//$osm_url = "https://open.mapquestapi.com/nominatim/v1/reverse.php?format=json&addressdetails=1&zoom=12&lat=". $image['latitude'] ."&lon=". $image['longitude'];
120120
//$osm_url = "http://localhost:8443/api/". $image['latitude'] ."/". $image['longitude'];
121-
$osm_url = "https://nominatim-xbgmsharp.rhcloud.com/api/". $image['latitude'] ."/". $image['longitude'] ."/". $sync_options['language'];
121+
//$osm_url = "https://nominatim-xbgmsharp.rhcloud.com/api/". $image['latitude'] ."/". $image['longitude'] ."/". $sync_options['language'];
122122
//print $osm_url ."<br/>";
123123

124124
// Ensure we do have PHP curl install
@@ -149,11 +149,11 @@
149149
);
150150
$context = stream_context_create($opts);
151151
if (false !== ($json = @file_get_contents($osm_url, flase, $context))) {
152-
// all good
152+
// all good
153153
//return $json;
154154
} else {
155155
// error happened
156-
//return false;
156+
//return false;
157157
$errors[] = "Error fetching reverse data";
158158
}
159159
}
@@ -166,10 +166,8 @@
166166
//print_r($response);
167167

168168
// If reponse include [address]
169-
if (isset($response) and isset($response['success']) and isset($response['success'][0]) and isset($response['success'][0]['result'])
170-
and isset($response['success'][0]['result']['address']) and is_array($response['success'][0]['result']['address']))
169+
if (isset($response) and isset($response['address']) and is_array($response['address']))
171170
{
172-
$response['address'] = $response['success'][0]['result']['address'];
173171
//print_r($response['address']);
174172
//print_r($sync_options);
175173
$tag_names = array();

include/functions_map.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
function osmcopyright($attrleaflet, $attrimagery, $attrmodule, $bl, $custombaselayer)
2828
{
29+
return '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>';
2930
$return = "";
3031

3132
if ($attrleaflet) $return .= '<a href="http://leafletjs.com/" target="_blank">Leaflet</a> ';
@@ -364,7 +365,7 @@ function osm_get_js($conf, $local_conf, $js_data)
364365
// we return directly as there is no addressPoints for GPX
365366
$js .= "\nvar Url = '".$baselayerurl."',
366367
Attribution = '".$attribution."',
367-
TileLayer = new L.TileLayer(Url, {maxZoom: 18, noWrap: ".$nowarp.", attribution: Attribution});\n";
368+
TileLayer = new L.TileLayer(Url, {maxZoom: 16, noWrap: ".$nowarp.", attribution: Attribution});\n";
368369
$js .= "var " . $divname . " = new L.Map('" . $divname . "', {" . $worldcopyjump . ", zoom: ".$zoom.", layers: [TileLayer], contextmenu: " . $local_conf['contextmenu'] . "});\n";
369370
$js .= $divname . ".attributionControl.setPrefix('');\n";
370371
$js .= "\nL.control.scale().addTo(" . $divname . ");\n";
@@ -373,13 +374,13 @@ function osm_get_js($conf, $local_conf, $js_data)
373374
// Create the map and get a new map instance attached and element with $divname
374375
$js .= "\nvar Url = '".$baselayerurl."',
375376
Attribution = '".$attribution."',
376-
TileLayer = new L.TileLayer(Url, {maxZoom: 18, noWrap: ".$nowarp.", attribution: Attribution}),
377+
TileLayer = new L.TileLayer(Url, {maxZoom: 16, noWrap: ".$nowarp.", attribution: Attribution}),
377378
latlng = new L.LatLng(".$local_conf['center_lat'].", ".$local_conf['center_lng'].");\n";
378379
$js .= "var " . $divname . " = new L.Map('" . $divname . "', {" . $worldcopyjump . ", center: latlng, ".$editor." zoom: ".$zoom.", layers: [TileLayer], contextmenu: " . $local_conf['contextmenu'] . "});\n";
379380
$js .= $divname . ".attributionControl.setPrefix('');\n";
380381
$js .= "var MarkerClusterList=[];\n";
381382
$js .= "if (typeof L.MarkerClusterGroup === 'function')\n";
382-
$js .= " var markers = new L.MarkerClusterGroup();\n";
383+
$js .= " var markers = new L.MarkerClusterGroup({maxClusterRadius: 30});\n";
383384
}
384385

385386
if ($local_conf['control'] === true)

0 commit comments

Comments
 (0)