forked from hnhx/librex
-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding
Maps
tab (merge pull request #85 from davidovski/maps)
Add Map tab
- Loading branch information
Showing
5 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
require "engines/text/text.php"; | ||
class OSMRequest extends EngineRequest { | ||
public function get_request_url() { | ||
|
||
$query_encoded = str_replace("%22", "\"", urlencode($this->query)); | ||
$results = array(); | ||
|
||
// TODO allow the nominatim instance to be customised | ||
$url = "https://nominatim.openstreetmap.org/search?q=$query_encoded&format=json"; | ||
|
||
return $url; | ||
} | ||
|
||
|
||
public function parse_results($response) { | ||
$json_response = json_decode($response, true); | ||
if (!$json_response) | ||
return array(); | ||
|
||
$results = array(); | ||
foreach ($json_response as $item) { | ||
array_push($results, array( | ||
"title" => $item["name"], | ||
"description" => $item["display_name"], | ||
"url" => "https://www.openstreetmap.org/node/" . $item["osm_id"], | ||
"base_url" => "www.openstreetmap.org" | ||
)); | ||
} | ||
return $results; | ||
} | ||
|
||
public static function print_results($results, $opts) { | ||
TextSearch::print_results($results, $opts); | ||
} | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.