Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Google Maps integration
I’m toying with the idea of adding in some kind of Google Maps integration into a site I’m working on. Looked around and can’t seem to find anything that helps.
I have several custom fields setup with things like addresses. I’d like to output on a page, a link to a google map location of a business using these custom fields, but try as I may, I can’t get through to anything that works and that I understand. And I’d like to avoid using gps coordinates, because this will fall apart under client use.
Anyone done anything like this?
Great, now even my car needs a tinfoil hat. :)
Offline
#2 2005-12-02 03:05:09
- Andrew
- Plugin Author
- Registered: 2004-02-23
- Posts: 730
Re: Google Maps integration
What exactly have you tried and isn’t working?
Offline
Re: Google Maps integration
Well, I guess I’m having trouble understanding how to add the custom fields to a link to call the map.
If you look here they have a Yahoo Maps link, which is basically what I’d like to do, with the info plugged into Textpattern.
I’m trying to get it so that down the line, my client can just add the business info into Textpattern, and it’ll create the link to the map automatically.
Is javascript necessary for something like this?
Great, now even my car needs a tinfoil hat. :)
Offline
Re: Google Maps integration
So I’m thinking you can do this one of two ways:
1) Create a plugin that takes in as attributes all of the information and then just creates the link as a string – all you do is append the street address on to http://maps.google.com/maps?q= . Make sure to insert ‘+’ between each word.
2) If you plan on accessing the business info more than once, you can create a table in the database to hold the information, an admin extension to update the information, and then create the plugin to create the link based off the information in the table.
Hope that helps.
P.S.: You don’t need any javascript. Just php. And maybe a little mysql if you use option 2.
Last edited by variaas (2005-12-02 03:43:33)
Offline
#5 2005-12-02 04:07:18
- Andrew
- Plugin Author
- Registered: 2004-02-23
- Posts: 730
Re: Google Maps integration
Ok, easy. Try this in an article form:
<a href="http://maps.google.com/?q=<txp:php>echo urlencode($thisarticle['custom1']);</txp:php>">Business Name</a>
Replace ‘custom1’ with whatever custom field you’re using. You could also use a second custom field to store the business name.
It’s not actually mandatory that you encode the contents of the custom field; your page just won’t validate. So in theory you could probably also just use this in combination with if_custom_field
:
<a href="http://maps.google.com/?q=<txp:custom_field name="custom1" />">Business Name</a>
That make sense?
Last edited by Andrew (2005-12-02 04:23:37)
Offline
Re: Google Maps integration
Hey, thanks variaas and Andrew. variass, your thoughts were cool, but I’m under too tight a time limit with this for that. Andrew, I actually had that second suggestion tried earlier, and it wasn’t working so I posted here thinking it didn’t work. Problem was I had it outside an article, so the custom field wasn’t getting added in.
I went ahead and added another custom field, called Map, to strip out commas, etc. It now works like a charm!
Thanks to both of you!
Great, now even my car needs a tinfoil hat. :)
Offline
Re: Google Maps integration
> greyfodder wrote:
It now works like a charm!
So…. you’re going to be posting the results of your labour, then…?
Offline
Re: Google Maps integration
You bet. The sites not live yet, but should be in a day or so.
Great, now even my car needs a tinfoil hat. :)
Offline
Re: Google Maps integration
Just realized I never came back to show my progress. Unfortunately, I’m not using TextPattern anymore, I switched the site over to ExpressionEngine, but if you’d like to see the links anyway, see here.
One thing I had trouble with was the number symbol in our addresses was throwing thr url off, so I added a plugin that would automatically format the link when the page is rendered so that number symbols get turned into the word “suite”. Now they work like a charm.
Last edited by greyfodder (2006-02-01 01:40:43)
Great, now even my car needs a tinfoil hat. :)
Offline
Pages: 1