Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2014-06-21 00:39:30

riot
Member
Registered: 2005-10-09
Posts: 22

Using TextPattern to manage locations on a Google Map?

I put together this little site for some friends but I’ve hit a snag. There’s a list of member bars that needs to be updated easily: http://dccraftbartendersguild.org/bars

I was hoping to appropriate Links for this. Members (Title) belong to Bars (Description), and they have a lat + long (URL ex. @38.905768,-77.042393). I’m sure there is some JS that needs to be involved, but I’m not much of a scripter.

Maybe someone knows of an easier way?

Offline

#2 2014-06-21 12:48:36

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,315

Re: Using TextPattern to manage locations on a Google Map?

I assume each bar is an article. Then you can proceed like so:

In the bottom region of your page there’s a script (the last one) whose crucial part looks like this:

['2 Birds 1 Stone', 38.914261, -77.032146],
['Ancora', 38.897765, -77.054842],
['Bar Pilar', 38.915152, -77.0317],
...
['The W', 38.896683, -77.033465],
['Wisdom', 38.88005, -76.984134] 

This structure can be filled with the output of an article_custom tag:

<txp:article_custom section="YOURSECTION" category="YOURCATEGORY" ETC.>
['<txp:title />', <txp:custom_field name="latitude" />, <txp:custom_field name="longitude" />]<txp:if_last_article><txp:else />,</txp:if_last_article>
</txp:article_custom>

{Edited to wrap article_custom around the tags, to me it’s so clear what I mean ;) – Uli}

Last edited by uli (2014-06-21 14:50:18)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#3 2014-06-23 13:34:11

aslsw66
Member
From: Canberra, Australia
Registered: 2004-08-04
Posts: 342
Website

Re: Using TextPattern to manage locations on a Google Map?

If you have increasing numbers of points to add to the map, it might be easier to use Textpattern to generate an XML page. You then point your Google map to the XML page to load all of the points and information for each one.

I had this working many years ago, but since then Google have upgrade the API for the maps and I haven’t figured out how to do it. I’m planning on getting around to it, but then I’ve been doing that for the best part of a year!

Offline

#4 2014-06-23 14:43:04

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,492
Bitbucket GitHub

Re: Using TextPattern to manage locations on a Google Map?

aslsw66 wrote #281584:

If you have increasing numbers of points to add to the map, it might be easier to use Textpattern to generate an XML page.

+1. I used to do this by making a Google-friendly .kml file, that worked.

Offline

#5 2014-06-23 18:23:23

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,953
Website GitHub

Re: Using TextPattern to manage locations on a Google Map?

You might also like to look at MarkerClusterer. The API’s quite terse, but there are plenty of examples about, and a page here with the front-of-house code in it you can steal plagiarise. It’s a blazingly fast library.

The json file that contains all the retailer location data was simply scraped from Textpattern as the other guys outlined using a <txp:article_custom /> tag to render all the custom fields and other article data in the right format. We used the indispensable adi_matrix plugin to manage the vast array of custom field data for all the articles.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB