-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev-places' of github.com:whosonfirst/whosonfirst-www-a…
…pi into dev-config Conflicts: .gitignore www/.htaccess www/include/config.php
- Loading branch information
Showing
17 changed files
with
315 additions
and
21 deletions.
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
*~ | ||
.vagrant | ||
www/include/config_dev.php | ||
www/include/config_local*.php | ||
www/include/secrets*.php | ||
www/test*.php | ||
|
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
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
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,47 @@ | ||
var mapzen = mapzen || {}; | ||
mapzen.places = mapzen.places || {}; | ||
|
||
mapzen.places.api = (function(){ | ||
|
||
var _api = undefined; | ||
|
||
var self = { | ||
|
||
'init': function(){ | ||
|
||
_api = new flamework.api(); | ||
_api.set_handler('endpoint', mapzen.places.api.endpoint); | ||
_api.set_handler('authentication', mapzen.places.api.authentication); | ||
}, | ||
|
||
'execute_method': function(method, data, on_success, on_error){ | ||
_api.call(method, data, on_success, on_error); | ||
}, | ||
|
||
'call': function(method, data, on_success, on_error){ | ||
_api.call(method, data, on_success, on_error); | ||
}, | ||
|
||
'endpoint': function(){ | ||
return document.body.getAttribute("data-mapzen-api-endpoint"); | ||
}, | ||
|
||
'authentication': function(form_data){ | ||
|
||
var key = document.body.getAttribute("data-mapzen-api-key"); | ||
|
||
if (! form_data.has("api_key")){ | ||
form_data.append("api_key", key); | ||
} | ||
|
||
return form_data; | ||
} | ||
} | ||
|
||
return self; | ||
|
||
})(); | ||
|
||
window.addEventListener('load', function(e){ | ||
mapzen.places.api.init(); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
window.addEventListener("load", function load(event){ | ||
|
||
var cb = function(map){ | ||
|
||
L.Mapzen.hash({ | ||
map: map | ||
}); | ||
|
||
var nearby_layer; | ||
|
||
var nearby = function(){ | ||
|
||
var center = map.getCenter(); | ||
|
||
var lat = center.lat; | ||
var lon = center.lng; | ||
|
||
var method = "whosonfirst.places.getNearby"; | ||
|
||
var args = { | ||
"latitude": lat, | ||
"longitude": lon, | ||
"per_page": 200, | ||
"extras": "geom:", | ||
}; | ||
|
||
var on_success = function(rsp){ | ||
|
||
var features = []; | ||
|
||
var places = rsp["places"]; | ||
var count_places = places.length; | ||
|
||
for (var i=0; i < count_places; i++){ | ||
|
||
var place = places[i]; | ||
|
||
var name = place["wof:name"]; | ||
|
||
var lat = place["geom:latitude"]; | ||
var lon = place["geom:longitude"]; | ||
|
||
var coords = [ lon, lat ]; | ||
|
||
var geom = { | ||
"type": "Point", | ||
"coordinates": coords, | ||
}; | ||
|
||
var props = place; | ||
|
||
var feature = { | ||
"type": "Feature", | ||
"geometry": geom, | ||
"properties": props, | ||
}; | ||
|
||
features.push(feature); | ||
} | ||
|
||
var feature_collection = { | ||
"type": "FeatureCollection", | ||
"features": features, | ||
}; | ||
|
||
nearby_layer = mapzen.places.map.add_geojson_to_map(map, feature_collection); | ||
}; | ||
|
||
mapzen.places.api.execute_method(method, args, function(rsp){ | ||
on_success(rsp); | ||
}); | ||
|
||
if (nearby_layer){ | ||
nearby_layer.remove(map); | ||
} | ||
}; | ||
|
||
map.on("dragend", nearby); | ||
map.on("zoomend", nearby); | ||
|
||
nearby(); | ||
}; | ||
|
||
mapzen.places.map.draw_nearby_map("map", cb); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
include("include/init.php"); | ||
loadlib("whosonfirst_places"); | ||
|
||
if ($id = get_int64("id")){ | ||
|
||
$place = whosonfirst_places_get_by_id($id); | ||
|
||
if (! $place){ | ||
error_404(); | ||
} | ||
|
||
$parent_id = $place["wof:parent_id"]; | ||
|
||
if ($parent_id != -1){ | ||
$parent = whosonfirst_places_get_by_id($parent_id); | ||
$place["wof:parent"] = $parent; | ||
} | ||
|
||
$GLOBALS['smarty']->assign_by_ref("place", $place); | ||
} | ||
|
||
$GLOBALS['smarty']->display("page_nearby.txt", $place); | ||
exit(); | ||
?> |
Oops, something went wrong.