We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Geocoding

Development and Programming

Mark Huot's avatar
Mark Huot
587 posts
16 years ago
Mark Huot's avatar Mark Huot

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!

       
PXLated's avatar
PXLated
1,800 posts
16 years ago
PXLated's avatar PXLated

Wow Mark…You’re a champ. Don’t have time to install and try now but can’t wait till I can :-)

PS: Any chance of a new Amazon Extension/Plugin? That’s been a want for some time :-)

       
ExpressionEngineer's avatar
ExpressionEngineer
148 posts
16 years ago
ExpressionEngineer's avatar ExpressionEngineer

Mark, that sounds brilliant. I’ll test it later today and report back any comments!

Great work!

:: andy

       
Cocoaholic's avatar
Cocoaholic
445 posts
16 years ago
Cocoaholic's avatar Cocoaholic

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
  • 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)

       
Ingmar Greil's avatar
Ingmar Greil
29,243 posts
16 years ago
Ingmar Greil's avatar Ingmar Greil

Yes, I get the same error. Had to disable the extension for the time being.

       
Mark Huot's avatar
Mark Huot
587 posts
16 years ago
Mark Huot's avatar Mark Huot

1.0.1 should fix that error.

       
ExpressionEngineer's avatar
ExpressionEngineer
148 posts
16 years ago
ExpressionEngineer's avatar ExpressionEngineer

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!

       
Shane Robinson's avatar
Shane Robinson
55 posts
16 years ago
Shane Robinson's avatar Shane Robinson

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?

       
ExpressionEngineer's avatar
ExpressionEngineer
148 posts
16 years ago
ExpressionEngineer's avatar ExpressionEngineer

Mark, I have some comments and will PM them in a few minutes.

       
Mark Huot's avatar
Mark Huot
587 posts
16 years ago
Mark Huot's avatar Mark Huot

@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).

       
Shane Robinson's avatar
Shane Robinson
55 posts
16 years ago
Shane Robinson's avatar Shane Robinson

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.

       
Shane Robinson's avatar
Shane Robinson
55 posts
16 years ago
Shane Robinson's avatar Shane Robinson

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.

       
Mark Huot's avatar
Mark Huot
587 posts
16 years ago
Mark Huot's avatar Mark Huot

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.

Thanks!

       
Shane Robinson's avatar
Shane Robinson
55 posts
16 years ago
Shane Robinson's avatar Shane Robinson

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.

Many Thanks!

       
Mark Huot's avatar
Mark Huot
587 posts
16 years ago
Mark Huot's avatar Mark Huot

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

       
1 2 3 Last

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.