Details
- I want to print a map base on
any
address that are stored in my<span>
- My address is :
410 walker street Lowell MA 01851
- My
<span>
isAddress: <span id="address" > 410 walker street Lowell MA 01851 </span>
- I want to use Google Map API for that
What I have tried
Address: <span id="address" > 410 walker street Lowell MA 01851 </span>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<!-- "Highlight a place or an address" -->
<iframe
width="600" height="450" frameborder="0" style="border:0"
src="
https://www.google.com/maps/embed/v1/place?q=
410+walker+street+Lowell+MA+01851
&key=*****
">
</iframe>
Here is my result
So far so good, everything is working, and it's work because I input the address manually
like this ?q = 410+walker+street+Lowell+MA+01851
but I don't want the input the address manually. How do I do this dynamically ? I need some suggestions - please.
My Approach
I was wondering if I can store my address in a variable
$address
$address = "
410 walker street Lowell MA 01851
";and finally print them back out as "410+walker+street+Lowell+MA+01851" in part of my HTML attribute
src=""
.
Questions
- I am not sure at all that this approach is the best practice for this.
- Is it possible ? How ?
- Can anyone help shed the light on this ?