Archive for June, 2007

Jun 30 2007

Google Maps in WordPress

Published by under web

Google map API’s are freely available and it is easy to embed a map into html with the code samples provided by google. It is a little more difficult to put a map on a wordpress page since WordPress’ code generation messes up the embedded Javascript. The solution is to put the Javascript into an external file and load it with an “src” link.

The Allegro Cyclery page on this site is a simple example of this approach.

The above is based on a site using version 2.0.8 of word press. When I migrated the approach to a version 2.1.3 based site the extra editor “functionality” messed up an html ‘division’ badly. So then I tried an “iframe” which put the ‘division’s’ html in an external file. That worked nicely on firefox, but failed badly (i.e. no map) on IE6 and Safari. At the moment, no good solution is at hand. I’ll have to go back to trying to work around WordPress’s “functionality”.

Update 2
The problem got more complicated before it got better. Since I couldn’t use iframes, I was back to trying to get the basic HTML version of Googel maps working. By a process of eliminations on the failing HTML code page, I got the problem down to something in the WordPress style sheet conflicting with Google maps. I had no good idea about the nature of the specific issue.

Before trying to pin down the issue with the style sheets, I decided to google some more and located a WordPress plugin that sanded like it would do exactly what I needed so I downloaded and installed it. No joy. Same problem. So I read through the comments on the plugin site and found that others were having the same problem with a theme called k2 which is what the site was using.. The theme in use was k2. To cut to the answer, via a couple of blog discussions, I found the solution to the style sheet conflict in the native code and in the plugin in this blog entry. Now everything works as it should. Google and “blogan’s” blog entry saved me a lot of time.

No responses yet