diff --git a/htdocs/map2.php b/htdocs/map2.php
index ed563a76..a5b6bc02 100644
--- a/htdocs/map2.php
+++ b/htdocs/map2.php
@@ -375,9 +375,7 @@ function output_cachexml($sWaypoint)
function output_namesearch($sName, $nLat, $nLon, $nResultId)
{
- global $login;
-
- $sName = '%' . $sName . '%';
+ global $login, $opt;
echo '' . "\n";
$rs = sql_slave("SELECT " . geomath::getSqlDistanceFormula($nLon, $nLat, 0) . " AS `distance`,
@@ -389,15 +387,34 @@ function output_namesearch($sName, $nLat, $nLon, $nResultId)
AND (`cache_status`.`allow_user_view`=1 OR `caches`.`user_id`='&3')
AND `map2_data`.`result_id`='&2'
ORDER BY `distance` ASC LIMIT 30",
- $sName,
+ '%' . $sName . '%',
$nResultId,
$login->userid);
+ $caches_found = 0;
while ($r = sql_fetch_assoc($rs))
{
echo '' . "\n";
+ ++$caches_found;
}
sql_free_result($rs);
- echo '';
+
+ if (!$caches_found && preg_match('/^[^\s[:punct:]]{2,}\.[^\s[:punct:]]{2,}\.[^\s[:punct:]]{2,}$/', $sName))
+ {
+ $result = @file_get_contents('http://api.what3words.com/w3w?key=' . $opt['lib']['w3w']['apikey']
+ . '&string=' . urlencode($sName));
+ if ($result)
+ {
+ $json = json_decode($result, true);
+ if (!is_null($json['words']) && !is_null($json['position']) && count($json['position']) == 2)
+ {
+ echo '' ."\n";
+ }
+ }
+ }
+ echo '' . "\n";
+
exit;
}
diff --git a/htdocs/templates2/ocstyle/map2.tpl b/htdocs/templates2/ocstyle/map2.tpl
index dd2cf0e6..26fe63ce 100644
--- a/htdocs/templates2/ocstyle/map2.tpl
+++ b/htdocs/templates2/ocstyle/map2.tpl
@@ -1749,6 +1749,20 @@ function mapsearch_click()
}
}
+ if (moSearchList.length==0)
+ {
+ var coords = xml.documentElement.getElementsByTagName("coord");
+ for (var nCoordIndex=0; nCoordIndex