From ae0cd70e3d6f8623e537573b93a715c337b64e07 Mon Sep 17 00:00:00 2001 From: Juhi Nadella Date: Thu, 13 Apr 2017 11:53:18 -0400 Subject: [PATCH] Use the multiplemarker.php class-- it contains geolocation and other stuff. still needs editing --- geolocation.html | 32 ++++++++++++ geolocation.php | 24 +++++++++ multiplemarkers.php | 106 ++++++++++++++++++++++++++++++++++++++++ phpsqlsearch_dbinfo.php | 8 +++ storelocator.php | 47 ++++++++++++++++++ 5 files changed, 217 insertions(+) create mode 100644 geolocation.html create mode 100644 geolocation.php create mode 100644 multiplemarkers.php create mode 100644 phpsqlsearch_dbinfo.php create mode 100644 storelocator.php diff --git a/geolocation.html b/geolocation.html new file mode 100644 index 0000000..ef6de87 --- /dev/null +++ b/geolocation.html @@ -0,0 +1,32 @@ +This function will be able to get the current location + + + + + + + + + + + diff --git a/geolocation.php b/geolocation.php new file mode 100644 index 0000000..d596a77 --- /dev/null +++ b/geolocation.php @@ -0,0 +1,24 @@ + 0 ){ + $result = $metadata['results'][0]; + echo $result['formatted_address']; + + } + + else{ + // no results + } +} + + + +?> diff --git a/multiplemarkers.php b/multiplemarkers.php new file mode 100644 index 0000000..4ae4b22 --- /dev/null +++ b/multiplemarkers.php @@ -0,0 +1,106 @@ + + +// first we will need to work on getting the current location using the google maps API + +/// we can get the current location by using the functions form the geolocation.html + + +// now we use the geolocation to find the list of nearby locations + +//https://developers.google.com/maps/documentation/javascript/store-locator?csw=1 is what we are using for reference + + + + + + + var currentlocation = getLoaction(); // this is where the current location will be stored + + + + + + + + + + diff --git a/phpsqlsearch_dbinfo.php b/phpsqlsearch_dbinfo.php new file mode 100644 index 0000000..10b16a8 --- /dev/null +++ b/phpsqlsearch_dbinfo.php @@ -0,0 +1,8 @@ +// this will connect it to the mySQL database + + diff --git a/storelocator.php b/storelocator.php new file mode 100644 index 0000000..2ffe4b4 --- /dev/null +++ b/storelocator.php @@ -0,0 +1,47 @@ +//provided by google for the geolocation api + +createElement("markers"); +$parnode = $dom->appendChild($node); +// Opens a connection to a mySQL server +$connection=mysql_connect (localhost, $username, $password); +if (!$connection) { + die("Not connected : " . mysql_error()); +} +// Set the active mySQL database +$db_selected = mysql_select_db($database, $connection); +if (!$db_selected) { + die ("Can\'t use db : " . mysql_error()); +} +// Search the rows in the markers table +$query = sprintf("SELECT id, name, address, lat, lng, ( 3959 * acos( cos( radians('%s') ) * cos( radians( lat ) ) * cos( radians( lng ) - radians('%s') ) + sin( radians('%s') ) * sin( radians( lat ) ) ) ) AS distance FROM markers HAVING distance < '%s' ORDER BY distance LIMIT 0 , 20", + mysql_real_escape_string($center_lat), + mysql_real_escape_string($center_lng), + mysql_real_escape_string($center_lat), + mysql_real_escape_string($radius)); +$result = mysql_query($query); +$result = mysql_query($query); +if (!$result) { + die("Invalid query: " . mysql_error()); +} +header("Content-type: text/xml"); +// Iterate through the rows, adding XML nodes for each +while ($row = @mysql_fetch_assoc($result)){ + $node = $dom->createElement("marker"); + $newnode = $parnode->appendChild($node); + $newnode->setAttribute("id", $row['id']); + $newnode->setAttribute("name", $row['name']); + $newnode->setAttribute("address", $row['address']); + $newnode->setAttribute("lat", $row['lat']); + $newnode->setAttribute("lng", $row['lng']); + $newnode->setAttribute("distance", $row['distance']); +} +echo $dom->saveXML(); +?>