Page 1 of 1
How do we use Google Maps to show locations of sellers?
Posted: Fri May 06, 2016 5:12 am
by simonmlewis
We are setting up a sales website for users to sell their own unique products.
We want the buyer to be able to see the location of the seller, down to their street name, in an embedded window.
I saw this:
http://html.shellcreeper.com/map-bound/
But it has to do it with the Long and Lat which we cannot get the seller to location.
So how do we do it? Does that information get sources dynamically from a Google API, and stored in a variable which then goes into our database, and if so, how?
Re: How do we use Google Maps to show locations of sellers?
Posted: Fri May 06, 2016 5:40 am
by requinix
You can use the Google Maps API server-side to look up the seller's address and get a lat/long. Store that in your database and use it with the map.
You could do the lookup on the client, but it will be the same value every time so there's no sense waiting until then.
Re: How do we use Google Maps to show locations of sellers?
Posted: Fri May 06, 2016 5:46 am
by simonmlewis
I just found a brilliant bit of code that does it.
Code: Select all
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<?php
$address_variable = "street here, town, postcode";
$address = str_replace(" ", "+",$address_variable);
?>
<iframe style="width:100%;height:50%;" frameborder="0" id="cusmap" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.it/maps?q=<?php echo $address; ?>&output=embed"></iframe>
Works just fine. No need for Lat and Long, even though I have since found a script that can gather it.
Re: How do we use Google Maps to show locations of sellers?
Posted: Wed May 11, 2016 2:03 pm
by thinsoldier
The google maps team has a github account with lots of example code for many thing you'd want to do like this and others
https://googlemaps.github.io/libraries
example:
https://github.com/googlemaps/js-marker-clusterer
Re: How do we use Google Maps to show locations of sellers?
Posted: Tue May 31, 2016 1:25 am
by pass4sureguide
good point:
use the Google Maps API server-side to look up the seller's address and get a lat/long. Store that in your database and use it with the map..