1 of 8
1
Geocoding
Posted: 15 November 2006 04:50 PM   [ Ignore ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1183
Joined  2006-01-05

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!

File Attachments
ext.geo_105.zip  (File Size: 7KB - Downloads: 317)
 Signature 

================================================
    Mark Huot
    http://markhuot.com
================================================

Profile
 
 
Posted: 15 November 2006 07:40 PM   [ Ignore ]   [ # 1 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  5862
Joined  2002-08-04

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

Profile
 
 
Posted: 16 November 2006 01:59 AM   [ Ignore ]   [ # 2 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  558
Joined  2004-07-22

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

Great work!

:: andy

 Signature 

ExpressionEngineer - custom solutions for EE

I EE

Profile
 
 
Posted: 16 November 2006 03:32 AM   [ Ignore ]   [ # 3 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  846
Joined  2002-02-05

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)

 Signature 

Member of the EE Pro Network

Profile
 
 
Posted: 16 November 2006 03:52 AM   [ Ignore ]   [ # 4 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  11967
Joined  2004-05-15

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

 Signature 

Everything will be good in the end. If it’s not good, it’s not the end.
No PM’s, please—use regular mail.

Profile
 
 
Posted: 16 November 2006 08:03 AM   [ Ignore ]   [ # 5 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1183
Joined  2006-01-05

1.0.1 should fix that error.

 Signature 

================================================
    Mark Huot
    http://markhuot.com
================================================

Profile
 
 
Posted: 21 November 2006 10:47 AM   [ Ignore ]   [ # 6 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  558
Joined  2004-07-22

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!

 Signature 

ExpressionEngineer - custom solutions for EE

I EE

Profile
 
 
Posted: 26 November 2006 02:58 AM   [ Ignore ]   [ # 7 ]  
Grad Student
Avatar
Rank
Total Posts:  86
Joined  2003-06-04

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?

 Signature 

Shane Robinson

http://www.barefeetstudios.com
http://www.beachwalks.tv
http://www.barefeetshop.com

Profile
 
 
Posted: 26 November 2006 04:01 AM   [ Ignore ]   [ # 8 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  558
Joined  2004-07-22

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

 Signature 

ExpressionEngineer - custom solutions for EE

I EE

Profile
 
 
Posted: 27 November 2006 06:29 PM   [ Ignore ]   [ # 9 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1183
Joined  2006-01-05

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

 Signature 

================================================
    Mark Huot
    http://markhuot.com
================================================

Profile
 
 
Posted: 27 November 2006 07:11 PM   [ Ignore ]   [ # 10 ]  
Grad Student
Avatar
Rank
Total Posts:  86
Joined  2003-06-04

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.

 Signature 

Shane Robinson

http://www.barefeetstudios.com
http://www.beachwalks.tv
http://www.barefeetshop.com

Profile
 
 
Posted: 27 November 2006 07:42 PM   [ Ignore ]   [ # 11 ]  
Grad Student
Avatar
Rank
Total Posts:  86
Joined  2003-06-04

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.

 Signature 

Shane Robinson

http://www.barefeetstudios.com
http://www.beachwalks.tv
http://www.barefeetshop.com

Profile
 
 
Posted: 02 December 2006 08:52 PM   [ Ignore ]   [ # 12 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1183
Joined  2006-01-05

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!

 Signature 

================================================
    Mark Huot
    http://markhuot.com
================================================

Profile
 
 
Posted: 03 December 2006 04:15 PM   [ Ignore ]   [ # 13 ]  
Grad Student
Avatar
Rank
Total Posts:  86
Joined  2003-06-04

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!

 Signature 

Shane Robinson

http://www.barefeetstudios.com
http://www.beachwalks.tv
http://www.barefeetshop.com

Profile
 
 
Posted: 03 December 2006 04:34 PM   [ Ignore ]   [ # 14 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1183
Joined  2006-01-05

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

 Signature 

================================================
    Mark Huot
    http://markhuot.com
================================================

Profile
 
 
Posted: 03 December 2006 04:58 PM   [ Ignore ]   [ # 15 ]  
Grad Student
Avatar
Rank
Total Posts:  86
Joined  2003-06-04

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.

I’ll let you know how it goes.

Thanks again for your attention.

 Signature 

Shane Robinson

http://www.barefeetstudios.com
http://www.beachwalks.tv
http://www.barefeetshop.com

Profile
 
 
Posted: 10 December 2006 04:27 AM   [ Ignore ]   [ # 16 ]  
Grad Student
Avatar
Rank
Total Posts:  86
Joined  2003-06-04

Aloha Mark,

As promised, posting back here to let you and everyone know IT WORKS and ROCKS!!

Thank you so much for the updated extension and your help.

Donation is already on the way.

Aloha and Happy Holidaze!

 Signature 

Shane Robinson

http://www.barefeetstudios.com
http://www.beachwalks.tv
http://www.barefeetshop.com

Profile
 
 
Posted: 10 December 2006 07:20 AM   [ Ignore ]   [ # 17 ]  
Grad Student
Avatar
Rank
Total Posts:  86
Joined  2003-06-04

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.

 Signature 

Shane Robinson

http://www.barefeetstudios.com
http://www.beachwalks.tv
http://www.barefeetshop.com

Profile
 
 
Posted: 27 December 2006 02:52 PM   [ Ignore ]   [ # 18 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  169
Joined  2004-04-08

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. smile

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?

 Signature 

~ I wish I could fix warp engines with duct tape & a pocket knife. ~

Profile
 
 
   
1 of 8
1
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 10:33 AM
Total Registered Members: 59014 Total Logged-in Users: 23
Total Topics: 69971 Total Anonymous Users: 12
Total Replies: 376984 Total Guests: 530
Total Posts: 446955    
Members ( View Memberlist )
Newest Members:  abahkinezoAdnan RajabrasstunerjishiHa.ahn.Mnmakoto kuwatawstuckey81unexpectedlyBelle