Experimenting with Google Maps API

12:07 am PHT

I’ve added a beta Map page to my second blog, Tanawing Pinoy, (now named Vista Pinas). Like the original Google Sightseeing, I plan this page to be an interactive embedded map pointing to all or a subset of the featured sights from the blog.

So I’ve signed up for a Google Maps API key and I’ve tested that I can put up a static map. The next step is to tie the map with the blog database. I’m using Dean Allen’s TextPattern for the blog’s CMS (it gives me greater flexibility than WordPress). Fortunately, I’ve added the GMaps URL associated with each post in a custom field for each post.

I still deciding on a nice and clean way to extract that URL information from the database and to convert it to data that can be used by the Map’s JavaScript. I’m looking at two ways. The first possibility is to create a standalone Perl/PHP script that will access the blog’s database and output the data in JSON, or something equivalent, to be read using an XmlHttpRequest call from the Map page.

The second possibility is for me to create a private TextPattern plug-in so that I can cleanly access the database and output the Map page itself directly containing all the data. This avoids the need to have a separate XmlHttpRequest call.

Both options seem to be equally fun to do, though I’m more comfortable doing the old-fashioned scripting route. The problem with creating a plug-in is that I still need to learn a bit of TextPattern’s API. And I’ve already had experience using AJAX so the first option would be the easiest to implement. It’s even easier since I could use Google’s readily available GXmlHttp class.

It’s something that I can hack on during the weekend.  =)

Filed under , , , , , and

Add your comment | 2 comments


Comment times are in Philippine time (+0800).


On 12:22 a.m., 9 Aug 2006, Kevin Todd wrote:

I’m curious as to whether you ever got this to work. My company has a database of the addresses of photographers and editors all across the U.S. and we were wanting to get a tie-in from the database to a google map that showed all the locations of the various people. Thanks in advance


On 7:18 a.m., 9 Aug 2006, seav wrote:

Kevin, I got it to work. I went with the first option and created a Perl CGI script. The map page JavaScript calls this script, which then accesses the database, extracts the needed data (I don’t use geocoding so things are a lot easier), and converts it into JSON output, which is then parsed by the JavaScript. See this Google map page.

Post your comment here

Comments moderated: Comments for this entry is now moderated. That means that the author will have to approve the comment before it can be viewed by the public.

Remember The Data Above? (Uses Cookies)

Comment shown to:

Comment notes

Your name and e-mail address are required. Your e-mail won't be displayed.