Source for file searchNear.php
Documentation is available at searchNear.php
jQuery.each(window.mapMarkers, function() {
window.map.removeLayer(this);
require_once 'Services/OpenStreetMap.php';
const KILOMETERS = 6372.8;
const NAUTUCAL_MILES = 3443.89849;
* Given two sets of lat/lon pairs, calculate the distance between them
* Distance defaults to being calculated in kilometers.
$sinHalfDeltaLat = sin(deg2rad($bLat - $aLat) / 2.0 );
$sinHalfDeltaLon = sin(deg2rad($bLon - $aLon) / 2.0 );
$lonSqrd = $sinHalfDeltaLon * $sinHalfDeltaLon;
$latSqrd = $sinHalfDeltaLat * $sinHalfDeltaLat;
return function ($a, $b) {
if ($a->distance == $b->distance ) {
return ($a->distance < $b->distance ) ? -1 : 1;
list ($k, $v) = explode('|', $_GET['q']);
if (isset ($_GET['lat'])) {
if (isset ($_GET['lat'])) {
$osm->loadXML ("./map.osm");
$results = $osm->search (array ($k => $v));
echo "==================\n\n";
foreach ($results as $result) {
if ($result->getType () == 'node') {
$bLat = $result->getLat ();
$bLon = $result->getLon ();
} elseif ($result->getType () == 'way' && $result->isClosed ()) {
$nodes = $result->getNodes ();
foreach ($nodes as $node) {
$n = $osm->getNode ($node);
$bLat = $bLat / sizeof($nodes);
$bLon = $bLon / sizeof($nodes);
// $distance = $distance * 1000; // convert to metres
$result->distance = $distance;
foreach ($results as $result) {
$tags = $result->getTags ();
$addrStreet = $tags['addr:street'];
$addrCity = $tags['addr:city'];
$addrCountry = $tags['addr:country'];
$addrHouseName = $tags['addr:housename'];
$addrHouseNumber = $tags['addr:housenumber'];
$openingHours = $tags['opening_hours'];
$oh->setValue ($openingHours);
$line1 = ($addrHouseNumber) ? $addrHouseNumber : $addrHouseName;
$distance = $result->distance;
echo " $bLat, " , $bLon, " (", number_format($distance, 4 ), "km)\n";
var marker = window.L.marker([",$bLat ,", ",$bLon," ]);
marker.addTo(window.map);
echo "window.mapMarkers.push(marker);";
if ($line1 != null && $addrStreet != null ) {
echo "{ $line1}{ $addrStreet}\n";
echo " <a href='tel:$phone'>$phone</a>\n";
if ($openingHours !== null ) {
} elseif ($open == true ) {
echo "window.map.panTo([",$bLat,", ",$bLon," ]);";
Documentation generated on Tue, 28 May 2019 19:19:08 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|