PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Mon May 25, 2020 12:54 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Fri May 06, 2016 5:12 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4434
Location: United Kingdom
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:

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?

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
PostPosted: Fri May 06, 2016 5:40 am 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6617
Location: WA, USA
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.


Top
 Profile  
 
PostPosted: Fri May 06, 2016 5:46 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4434
Location: United Kingdom
I just found a brilliant bit of code that does it.

Syntax: [ Download ] [ Hide ]
<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.

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
PostPosted: Wed May 11, 2016 2:03 pm 
Offline
Forum Contributor

Joined: Fri Jul 20, 2007 11:29 am
Posts: 367
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

_________________
Warning: I have no idea what I'm talking about.


Top
 Profile  
 
PostPosted: Tue May 31, 2016 1:25 am 
Offline
Forum Newbie

Joined: Tue May 31, 2016 1:17 am
Posts: 1
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..


Last edited by requinix on Tue May 31, 2016 2:53 am, edited 1 time in total.
removing advertising


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group