- This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
Viewing 6 posts - 1 through 6 (of 6 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › Converting address into Google Maps link
Howdy folks,
I’m working on a way to convert a text address to Google Maps link, I [found this solution on stackoverflow](http://stackoverflow.com/questions/1300838/how-to-convert-an-address-into-a-google-maps-link-not-map “”), the only problem is, the output removes the line breaks and spans I have in place. I don’t know javascript well enough to figure out how to edit this to even possibly just insert the anchor tag, without removing the html tags I already have in place.
Here’s the [pen](http://codepen.io/ChrisPlz/pen/zKfln “”).
Any help is greatly appreciated.
Obviously it works but it looks like it’s converting the whitespace to the ‘+’ character.
Are the breaks and spans important to the result in GMaps?
Ohhh…you mean that you want the address in the browser as it’s coded and not shoved into a string.
That being the case, I think the best thing to do is to have a set of spans (address lines if you will), let the JS grab the text inside each one and the concatenate all of that….then only submit it to GMaps on a click.
I confess I’m at an early stage with JQuery but that would seem to be the logical way to do it.
Anyone else?
I think you’ll need to translate any breaks or gaps into + symbols to create this.
I recently did a “Get Directions” input on a customer site and it literally posts the plain text address via GET to http://maps.google.com/maps so you may be able to do something similar.
I’ll fire up a codepen and see what I can make.
I am REALLY new to JS/JQ but…..http://codepen.io/Paulie-D/pen/uCvHk
Got it – http://codepen.io/andyunleashed/pen/CGkpf
Edit: I just realised I completely missed the point of what you’re trying to accomplish! Didn’t spot your original codepen, will have a look at that as well, but the text input turned into a link is pretty cool also!