diff --git a/favicon.ico b/favicon.ico index 8b13789..c78c241 100644 Binary files a/favicon.ico and b/favicon.ico differ diff --git a/index.html b/index.html index 7862d38..d748d58 100644 --- a/index.html +++ b/index.html @@ -272,6 +272,21 @@ function dolookup(words) { try { words = words.trim().toLowerCase().replace(/\s+/g, ' '); + + if (!/^[a-z ]+?$/i.test(words)) { + // Not a FixPhrase, run a search + $.getJSON("lookup.php", { + search: words + }, function (resp) { + if (resp.status == "OK") { + lookupAndShowCoords(resp.coords[0], resp.coords[1]); + } else { + alert("Error: " + resp.msg); + } + }); + return; + } + var coords = FixPhrase.decode(words); showLocationPopup(coords[0], coords[1], coords[3], coords[2]); diff --git a/lookup.php b/lookup.php index 553e8b1..b49293d 100644 --- a/lookup.php +++ b/lookup.php @@ -57,8 +57,21 @@ try { $lon ] ]; + } else if (!empty($_GET["search"])) { + $resp = file_get_contents("https://data.netsyms.net/v1/gis/geocode/?address=" . urlencode($_GET["search"])); + $data = json_decode($resp, true); + + if ($data["status"] == "OK") { + $output = [ + "status" => "OK", + "action" => "geocode", + "coords" => $data["coords"] + ]; + } else { + throw new Exception($data["message"]); + } } else { - throw new Exception("Must supply either a string of words or a latitude/longitude pair."); + throw new Exception("Must supply either a string of words, a latitude/longitude pair, or a search query."); } } catch (Exception $ex) { sendJsonResp($ex->getMessage(), "ERROR");