Close and Go BackBack to Viget

Google Maps jQuery Plugin with ExpressionEngine

Keith Muth
Keith Muth, ON THE TOPIC OF Development and General and Javascript
8/5
2009
5

Yesterday Carolyn blogged about a site we did for NCGives. One of their requests was to have the ability to add locations to an ExpressionEngine weblog and have them display on a Google Map. Seemed easy enough until I realized we also had to make external map controls, display content both in the map bubble and on the page, color code the map points, and auto zoom/center the map. I looked around for existing solutions, such as the SL Google Map Extension, but nothing I found did exactly what our client was requesting. I knew that one of our developers, Brian Landau, had experience with Google Maps, so I started talking to him about what we could do.

Initially, I setup a weblog in ExpressionEngine that would take in all of the location information. Aside from the standard content about the location, I put in two text input custom fields for longitude and latitude. Since the client wouldn't know the longitude and latitude coordinates, I put in a link to this website in the field instructions, which converts a standard address.

After the weblog was setup I worked with Brian to get a template outputting markup that would work with his Google Maps plugin. It was easy with ExpressionEngine because I could open a single weblog entries tag and output the variables the plugin could use to create the map. The client wanted to show just the location titles below the map and have them link to the pin point, so JavaScript creates that link and hides the rest of the content. One of the nice things about doing it this way is that even if JavaScript is turned off and you can't see the map, you still get all of the ExpressionEngine content displaying on the page.

See the map at http://ncgives.org/map/

You might notice that the jQuery metadata plugin is using the "data" attribute to grab the id, longitude, latitude, and category (which determines the color of the pin point). Brian is working on adding support for microformats instead using the data attribute, so stay tuned for that.

So if you're looking to put a Google Map in your ExpressionEngine project, check out this blog post about his creation of his jQuery Google Maps plugin over on the Viget Extend blog, or find more information on how to use it on Github.

bob Budd said on 08/07 at 11:22 AM

i’m in the middle of working on the same project - map in expression engine using jquery as our js library to run it.

i’d suggest maybe you all went the long way around. 

expression engine is very good about creating dynamic xml files, so they are created as they are asked for.  this way the content going to your xml doc is always current.  and since jquery can rip through xml like a hot knife through butter, it’s easy to get your info that way and pass it on to the map through a create marker function.

Hambo said on 08/09 at 09:30 PM

Hey Bob,

I’m interested to know how you accomplish this your way. Can you do a brief write up?

Keith Muth said on 08/10 at 10:23 AM

@bob I would also really like to see an example of the code you’re using, if you’re willing to share it.

bob said on 08/12 at 03:31 PM

hi guys -

i posted a (hopefully) sensible step-by-step in how to accomplish it in our blog.

- bob

Phil said on 09/14 at 05:16 AM

Whatever happened to the good old include iFrame map ;)

Commenting is not available in this weblog entry.

We're The Designers

at Viget Labs. We write about design news, trends, techniques, buildout, inspiration, CSS, and our projects.

What's a-twitter?

Follow us @VigetInspire for updates of the goings-on here or @Viget for more from all of the Viget crew. #thatisall

Recent Comments

We use it a lot at Hashrocket now. It’s made life a lot easier when coding large-scale applications.

The hardest part of SASS is going back to coding regular CSS after you’ve been in it...

Subscribe to Comments RSS RSS

Contact Us

Have any questions, comments, ideas, or secrets to share? Let us know.


How many days in a non-leap year?

Sorry, you need to have Javascript enabled to use this form. (Don't blame us, blame the spammers!) If you'd like to contact us, please visit our Contact page.