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:
{office_location_raw}
{latitude}, {longitude}
{/office_location_raw}
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.
Have fun!
Hi Mark,
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
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)
Aloha Mark,
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:
Thanks!
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:
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.
Many Thanks!
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
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.