I’ve had some fun developing an extension that provides Google Maps geocoding directly in the CP. To use this extension you’ll have to sign up for a site key from Google. Then enter it in the extension settings. From there you can add a new geo field and when you go to publish you’ll see a blank Google Map. Clicking on the map will add a marker and then clicking on a marker again will remove it. You can also drag the markers around the map (all thanks to the wonderful GMaps2 API).
To use this in a template you can just drop the field name and it will output a 300x300 map. You can customize the width/height with their respective attributes. So, assuming my field was named office_location the code would look like this
{office_location width="400px" height="200px"}
There are a bunch of attributes you can set, they are as follows:
key=”” To override the key set up in your CP.
x=”” To override the default centering.
y=”” To override the default centering.
zoom=”” To override the default zoom.
center_on_points=“false” To have the map use the default centering, not the center of the points
show_empty=“true” Will show a map even when no points have been defined
Finally, if you don’t like my default map then you can get to the raw data as follows:
To clarify, just append a “_raw” to the field name and then inside of that pair you can use the {latitude} and {longitude} variables to return each points location. The pair will loop for as many locations as you have.
I just tried this extension and I’m experiencing some difficulties.
I am seeing the following error in my template:
Notice: Undefined variable: all_fields in /Library/WebServer/Documents/ee151/system/extensions/ext.geo.php on line 470
- Installation went fine
- I can add/remove markers when creating a new entry, this works great
- When I ty to edit an entry in the CP, the map isn’t there anymore so I can’t edit it.
- In my template, the space where the map should be is visible but the map itself is not.
As you can see I am testing locally on my Mac which might cause this behaviour, but I’m not sure. (I’ll test later on a live server)
I’m so sorry Mark, I should have replied with my comments last week and now I’ve misplaced my notes.
Will make an effort to install and play around with it later this week. Many thanks for making it available!
How thrilled I was when I Googled for a Google map EE plugin and found your extension. But, alas, it doesn’t seem to work. Specifically, it doesn’t save the value to the exp_weblogs_data table.
I found that if I don’t enter a default X and Y location, it doesn’t display/update anything in the CP. If I do enter an X and Y in the ext settings, it does display that default location, and will update to the new location as I type the address into the field, but it won’t save ANY values typed into the field upon clicking Update.
I’ve deleted and recreated the field several times and disabled and enabled the extension hoping something would “kick in” and begin working. No luck.
I also disabled the extension, disabled all extensions (your GEO is my only extension), deleted the field…then re-enabled extensions, re-enabled the GEO extension, and then created a new field. Nothing works.
I’m using EE 1.5.1.
Anyone else having this problem or been able to get this extension to work?
@Shane: The text box is not meant to store values, it’s just a quick find box to re-center the map. Use it to find an address, then press return and a point will be added. Unless you see a new pushpin show up the point will not be saved.
Also you’ll need that default XY or it will default to NYC (at least that’s the thought, i’ll check it out though).
Mahalo Mark! I’ll give this a try and let you know how it goes.
FYI, for me, if no default XY are entered in the Ext Settings, no default map shows up and no map shows up when an address is typed into the field. So for now I’m leaving a default XY and will try your instructions above.
Just back from testing and here’s how it works for me:
1) When creating a new entry, the default XY shows below the Geolocation field. I type in the new address, the map updates, I hit “Return” and a pin shows up. I then click Submit and everything works on the front end of the site as well.
2) I return to edit the entry I just created, there is no map, default XY or otherwise displaying below the Geolocation field. I type in a new address, no map displays, I hit “Return” and EE sees that as clicking the “Preview” button. The page refreshes and shows the same coordinates in the preview as what was entered for the very first time.
3) So for new entries/posts, or for posts that currently have never had a Geolocation value, the default map displays and an address can be entered. For existing posts that I try to edit that already have Geolocation values, no may displays and hitting the Return key after entering a new address forces EE to submit a Preview and the new Geolocation address is not saved.
From my experience there is no way to update or delete a Geolocation.
With our clients this won’t work as they always have typos and will wanting to be adding and removing maps at the discretion of their own clients whose addresses will be listed on our client’s site.
This is cool and I’d be willing to pay for an extension that allowed updates and deleting of the XY values.
Shane I’ve updated this to version 1.0.2 to fix a few of your bugs. Let me know how you fare. Also a few questions:
1. What OS are you using
2. What browser are you using
3. What version of EE
4. Can you post a screen shot of the “values appearing below the geo field”? I can’t recreate that no matter how many browsers I try.
Aloha Mark. I couldn’t find the update on your http://docs.markhuot.com/ page. I tried directly downloading http://docs.markhuot.com/ext.geo_102.zip but it still gave me a 101.zip and the ext.geo.php file had date of 2006-09-06.
Answers to your ?s above:
1. Mac 10.4.8.
2. Tried it in both Firefox 2.0 and Safari 2.0.4 (build 419.3).
3. EE 1.5.1. Have since upgraded to 1.5.2 but haven’t had time to get back to checking this stuff.
4. What I meant was, the default map and location (centered) displays below the Geo text field into which you’re supposed to enter the new address.
Basically, on a brand new post/entry, everything works. But if you try to edit that entry later, no map shows up and regardless of what address you put into the field, it doesn’t update.
LMK how to DL v1.0.2 and I’ll give it a whirl in EE 1.5.2.
1.0.2 is at the top of the thread. I’ve also tried to reproduce your errors and have so far come up short, the map always shows up for me in IE, Firefox, and Safari no matter wether I’m publishing a new entry or editing an existing entry. Can you post a list of your other installed extensions?
Thanks
D’oh! Thanks for the pointer to the top of the thread.
I’ll install 1.0.2 and experiment later today or ASAP. I have over 1,100 entries to import from a FileMaker database into an EE project we’re trying to get launched this week. That’s the main reason I haven’t been able to get back to this for a few days.
Weeeellll…. Few problems after all but I don’t think it’s the plugin:
Using a Thickbox iFrame to display the map when a link is clicked:
1) Firefox on both Mac and PC and IE7 won’t show the pin. Safari works fine.
2) Firefox on both Mac and PC and IE7 won’t show the correct map. Safari works fine.
3) On the map, clicking the “Return to the last result” button in the middle of all the out pointing arrows takes you back to the default location entered into the Extension settings.
#3 is somehow related to the extension. But 1 and 2 are possibly a problem with prototype.js or Thickbox.
I’m not having a problem with Prototype and can display a map and pin in FF and IE within a template. I was trying to use the map output in a Thickbox iFrame and it is well documented, I found, that Thickbox isn’t working with the Google Map API in FF and IE.
For now I guess we just display the maps in the template.
If anyone trips across a fix or a fix becomes available, would be great if they post it back here. I’ll do the same.
Great stuff! I was just starting to create a complicated weblog setup with latitude and longitude and trying to put it out as a map in the templates, when I stumbled upon this extension. Thanks so much! Donation is on it’s way.
I’m new to this whole google map stuff, and one of the things I want to achieve is to show different locations (i.e. different weblog entries) in one big map. Shouldn’t be too hard, the possibilities are all in there - I just need a pointer to get me started. Anyone know of a more concise documentation than the google api blog?