Google Maps + Gallery
peterm
Joined: 2004-12-13
Posts: 39 |
![]() |
Summary: For more information, you don't need to read the 500+ posts in this thread. There's a projection page on: http://codex.gallery2.org/index.php/Gallery2:Modules:Map Discussion and Support Bugs and Feature Requests The Admins for the project are Galmoid and myself (let us know if something isn't quite right) Thanks ! ------------------------- ____________________________________________________________________ Imagine if you had the gps coordinates for the pictures you took, and added them either in the tag in the image, or into the gallery, and for each album, you can have a map that would show where each image was taken... and you can click on each marker to bring you to other images from the same area. Now that would be sweet, way above my skills, but what a sweet add on it would be. Is it possible with the new Google Maps APIs released? Heres a link to somtething like I'm thinking, but the gallery version would have more photos. Click on the red marker near Paraguay. |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
someone would have to write such a G2 module, but yes, it's possible. |
|
Arjen
Joined: 2003-06-09
Posts: 47 |
![]() |
This is indeed a great idea! |
|
drhiii
Joined: 2003-04-27
Posts: 397 |
![]() |
I had have had a lot of questions about that for some nonprofit petroglyph projects for instance. GPS fields in G2 would be the berries! peterm wrote:
Imagine if you had the gps coordinates for the pictures you took, and added them either in the tag in the |
|
f33dback
Joined: 2005-07-06
Posts: 21 |
![]() |
This would be great, someone please do this. |
|
LarryDoliver
Joined: 2003-12-31
Posts: 35 |
![]() |
I started looking at this, and it really should not be hard to get the basics working. This is what I have to date: All I need to do it put the GPS coordinates in a custom field, and edit a theme to replace the album page with something like this. Couple things I'm not certain about, can anyone help on these? thanks... |
|
LarryDoliver
Joined: 2003-12-31
Posts: 35 |
![]() |
Got it working!!! This takes two custom fields: kinda clunky, and not 100% what I wanted (to be able to see children and grandchildren items), but it works. album file attached. |
|
nivekiam
![]()
Joined: 2002-12-10
Posts: 16504 |
![]() |
LarryDoliver, there's no attachment to your post. Try zipping it. |
|
mindless
![]()
Joined: 2004-01-04
Posts: 8601 |
![]() |
LarryDoliver, super cool! |
|
f33dback
Joined: 2005-07-06
Posts: 21 |
![]() |
That's the shizzle Larrycan you gives a module? or some way to use this? |
|
jvanbrecht
Joined: 2005-08-13
Posts: 4 |
![]() |
That rocks, although I prefer the version that shows an image, with a link to the associated gallery, rather then directly to the image. |
|
LarryDoliver
Joined: 2003-12-31
Posts: 35 |
![]() |
nivekiam wrote:
LarryDoliver, there's no attachment to your post. Try zipping it. how 'bout now... |
|
LarryDoliver
Joined: 2003-12-31
Posts: 35 |
![]() |
jvanbrecht wrote:
That rocks, although I prefer the version that shows an image, with a link to the associated gallery, rather then directly to the image. That's totally possible, just use ablums instead of images with the GPS data: http://tautologous.com/gallery2/travel/ THis one has some linking to images, some to ablums. I don't handle permissions well, so you fine folks out there will be lock out of some of these... |
|
nivekiam
![]()
Joined: 2002-12-10
Posts: 16504 |
![]() |
LarryDoliver, that is sooo damn cool. Thank you for sharing!!! |
|
nivekiam
![]()
Joined: 2002-12-10
Posts: 16504 |
![]() |
I've added your mod to the User Contribution page, http://codex.gallery2.org/index.php/Gallery2:UserContributions#Mods.2FPatches |
|
jvanbrecht
Joined: 2005-08-13
Posts: 4 |
![]() |
Okay, I am going to pretend I am stupid here (although sometimes I am), this is my first foray into g2, and I am by no means a developer (netsec by trade), so what are the odds I can get a few basic instructions, or a pointer to someplace that will provide a quick explanation of how to add minor applications. I am at work, so I don't really have the time to search, if no response, I will search when I get home, but its Friday, and I am being lazy.. |
|
nivekiam
![]()
Joined: 2002-12-10
Posts: 16504 |
![]() |
Here's one place to start, check out the Developer section here, http://codex.gallery2.org/index.php/Main_Page As well as here, http://gallery.menalto.com/modules.php?op=modload&name=phpWiki&file=index&pagename=Development%20Documents (I don't know if everything has been ported over to the new site yet) |
|
f33dback
Joined: 2005-07-06
Posts: 21 |
![]() |
Say Larry I'm not the sharpest tool in the shed when it comes to this stuff do you have a little tutorial or how to add the tpl file? like where to go and what exactly to do? By the way I did browse the above links but that's not doing much for me at my level. |
|
LarryDoliver
Joined: 2003-12-31
Posts: 35 |
![]() |
f33dback wrote:
...do you have a little tutorial or how to add the tpl file? like where to go and what exactly to do? Sure - should have done this is the first place. There are two parts to this: (1) setting up a new theme (clone of matrix) and making some tweaks and (2) getting the google mapkey and GPS data attached to albums and images. So (1): then (2): that's how I remember it. Let me know if it works, and post a link, too... |
|
risp
Joined: 2004-04-09
Posts: 8 |
![]() |
I don't get the part about the GPS custom field. Do i have to add a GPS field for the album or the photo? It's impossible to add GPS to photo and album. EDIT nevermind i should read better next time Anyway it works great in Opera but in IE6 i get this error: Opertion aborted. This also happens on your site |
|
samkuhn2
Joined: 2004-04-13
Posts: 60 |
![]() |
LarryDoliver wrote:
Got it working!!! Nice work Larry! I have a few requests/suggestions. |
|
jvanbrecht
Joined: 2005-08-13
Posts: 4 |
![]() |
Everything you need to know about google maps, including the pinpoints and colours, is here. |
|
jvanbrecht
Joined: 2005-08-13
Posts: 4 |
![]() |
Okay, so I followed the instructions (I already had a number of mapkeys which work in static html files), so I generated the mapkey for images.vanbrecht.com/jason/kim I modified the theme. |
|
LarryDoliver
Joined: 2003-12-31
Posts: 35 |
![]() |
jvanbrecht wrote:
I guess my question is.. when the template is called, does it take into account the URL redirect, or does it want the original path that gallery would use if URL rewrite was turned off. I registered keys for things like "http://tautologous.com/gallery2/travel" |
|
LarryDoliver
Joined: 2003-12-31
Posts: 35 |
![]() |
samkuhn2 wrote:
I have a few requests/suggestions. I'm content with not differentiating albums and photo's, but it would be trivial to make that improvement. For #3, that's a really good idea - but I don't tag each photo in an album with gps data from exactly where the photo was taken. Just city-level resolution on the pins. If I do head this way, then your #1 comment would be a good idea... Here's my idea for an improvement: add a world map on the edit photo page to click to add GPS data... |
|
risp
Joined: 2004-04-09
Posts: 8 |
![]() |
Am I the only one with problems when viewing with IE 6? In IE it's impossible to see the page |
|
LarryDoliver
Joined: 2003-12-31
Posts: 35 |
![]() |
risp wrote:
Am I the only one with problems when viewing with IE 6? In IE it's impossible to see the page No - you are not alone. Can you get to this site (another, very slick, google map photo implementation) |
|
risp
Joined: 2004-04-09
Posts: 8 |
![]() |
LarryDoliver wrote:
I can see that page without any problems in IE. I'm tried to find the problem in the code but no luck so far |
|
LarryDoliver
Joined: 2003-12-31
Posts: 35 |
![]() |
Doesn't seem to be a URL_rewrite issue (it's broken in both cases) kinda stuck here... I get the same apache requests from both IE and firefox (from the same machine): IE: "GET /gallery2/v/travel HTTP/1.1" 200 11538 "-" "GET /gallery2/themes/map/theme.css HTTP/1.1" 200 11978 "http://tautologous.com/gallery2/v/travel" "GET /gallery2/images/galleryLogo_sm.gif HTTP/1.1" 200 3488 "http://tautologous.com/gallery2/v/travel" "GET /gallery2/main.php?g2_view=imageframe.CSS&g2_frames=none HTTP/1.1" 200 171 "http://tautologous.com/gallery2/v/travel" "GET /gallery2/themes/map/images/icon_path_separator.gif HTTP/1.1" 200 106 "http://tautologous.com/gallery2/v/travel" firefox: "GET /gallery2/main.php?g2_view=imageframe.CSS&g2_frames=none HTTP/1.1" 200 171 "http://tautologous.com/gallery2/v/travel/" "GET /gallery2/themes/map/theme.css HTTP/1.1" 200 11978 "http://tautologous.com/gallery2/v/travel/" "GET /gallery2/v/travel/ HTTP/1.1" 200 21008 "-" "GET /gallery2/images/galleryLogo_sm.gif HTTP/1.1" 200 3488 "http://tautologous.com/gallery2/v/travel/" "GET /gallery2/themes/map/images/icon_path_separator.gif HTTP/1.1" 200 106 "http://tautologous.com/gallery2/v/travel/" The only difference seems to be the order... |
|
LarryDoliver
Joined: 2003-12-31
Posts: 35 |
![]() |
OK - I think I have it working now. But, there are some funny style-sheet issues lingering. Can you css wizards load the page the take a look how I could fix this? http://tautologous.com/gallery2/travel (the issue was that IE6 barfs on <script> tags that are inside table, div, or other containers. Seems to be a poorly conceived security "feature") |
|
nivekiam
![]()
Joined: 2002-12-10
Posts: 16504 |
![]() |
Looks like the script issue may just be a typo: You have a script tag starting and never ending in the document on line 12 Here's the CSS validator results too: Probably get something better once the page validates to XHTML strict. |
|
risp
Joined: 2004-04-09
Posts: 8 |
![]() |
Yeah it seems to work in IE 6 now. But now I get a javascript error: Line: 14 Char: 5 Error: Syntax error Code: 0 URL: http://tautologous.com/gallery2/travel Not perfect yet but it's getting better every time :D |
|
LarryDoliver
Joined: 2003-12-31
Posts: 35 |
![]() |
ahh - total rookie mistakes. I validated on Sunday, but guess I made changes since then. All seems to be working now... latest source attached |
|
swordfish
![]()
Joined: 2004-10-01
Posts: 388 |
![]() |
**LarryDoliver, This sounds really cool! Forgive my ignorance but how does one go about using this mod? Before I attempt to install I'm not sure if I need instructions for your mod or this Google map api widget. Any hints much appreciated. Yea, this implementation is awesome --> http://www.panoramio.com/ Thanks! |
|
f33dback
Joined: 2005-07-06
Posts: 21 |
![]() |
Swordfish this is what Larry posted before: So (1): then (2): that's how I remember it. Let me know if it works, and post a link, too... Hope that helps. |
|
swordfish
![]()
Joined: 2004-10-01
Posts: 388 |
![]() |
hey f33dback, Thanks for the details!! I'll give this a shot. |
|
gilrim
Joined: 2005-08-28
Posts: 32 |
![]() |
http://www.google.com/apis/maps/signup.html |
|
LarryDoliver
Joined: 2003-12-31
Posts: 35 |
![]() |
I've made a few updates, check 'em out at http://tautologous.com/gallery2/travel Images and albums get different colored icons, fixed bugs, etc How do you post attachments in the new forum? |
|
HorsePunchKid
![]()
Joined: 2005-05-04
Posts: 89 |
![]() |
It's quite a hack, but I've got a map working here. I'm going to try to turn it into a module, though, since that will probably match my needs better. Can anyone here give me a clue on how to:
I figure the fetching IDs should be easy, but I'm having trouble even finding code that does something similar. I could write the SQL if I knew where to send it. Getting the data for the IDs can be done through something in GalleryCoreApi, I think, but I'm not sure what exactly (maybe tracing LoadCommonTemplateData will give me an idea). The last step I've got more ore less figured out, I think. |
|
HorsePunchKid
![]()
Joined: 2005-05-04
Posts: 89 |
![]() |
I should mention that my map is based on LarryDoliver's code. Thanks so much for that, Larry! |
|
LarryDoliver
Joined: 2003-12-31
Posts: 35 |
![]() |
HorsePunchKid wrote:
Can anyone here give me a clue on how to: This code iterates through all children looking for nonempty custom fields called GPS... {foreach from=$theme.children item=child} {g->callback type="customfield.LoadCustomFields" itemId=$child.id} {if isset($block.customfield.LoadCustomFields.fields.GPS)} var comment = 'Image: {$child.title|markup} taken on {g->date timestamp=$child.originationTimestamp}<br><a href="{g->url arg1="view=core.ShowItem" arg2="itemId=`$child.id`"}"> {g->image id="%ID%" item=$child image=$child.thumbnail class="%CLASS% giThumbnail"} </a>'; {if $child.canContainChildren} createMarker(new GPoint({$block.customfield.LoadCustomFields.fields.GPS}),comment,Redicon); {else} createMarker(new GPoint({$block.customfield.LoadCustomFields.fields.GPS}),comment,Greenicon); {/if} {/if} {/foreach} Is that what you're looking for? |
|
HorsePunchKid
![]()
Joined: 2005-05-04
Posts: 89 |
![]() |
Thanks, but not quite. The problem (for me) is that that assumes that the items you want to plot are all children of the current album. My goal is to have a single map that will show every item in my gallery that happens to have associated GPS coordinates. So I need to be able to look for any possible item. (Realistically, I would probably limit it to albums instead of individual photos.) Currently, I have just hardcoded (in theme.inc) a list of "map points" with associated data (ID, coordinates, description) and thrown them into an array that I can access via {$theme->mapPoints}, then loop over them in basically the same way that your code does. My plan is to turn this into a module. The module would probably store the Google API key, since it's probably reasonable to assume that that would work site-wide. Then I'd probably need to set up some kind of URL rewrite to make http://foo.com/gallery/map/ point to http://foo.com/gallery/main.php?g2_view=map:ShowMap or something like that. |
|
LarryDoliver
Joined: 2003-12-31
Posts: 35 |
![]() |
Yeah - I see where you're going. If you want the map to be the starting point for all navigation - just use what I posted, and have all albums as children to a single parent. That's what I do, and it works pretty well - I had to move oodles of albums around to flatten the tree to get rid of grandchildren and great-grandchildren (I'm not totally done with this - but it got me where I'm happy with it...) On the API key, what I did was edit the URL rewrite rules from "v/album" to just "album" - that way http://tautologous.com/gallery2/travel is the same directory (to google) as any other top-level album. Not a perfect solution, but it works for me since I flattened out my map (travel) area anyway... On another note, I'm thinking about having tiny (50x50?) thumbnails of images/albums along the right or bottom of the map. Click a thumbnail, the map scroll/zooms in to that area. Should be trivial to implement, just need to get around to it... |
|
swordfish
![]()
Joined: 2004-10-01
Posts: 388 |
![]() |
hey Larry, Quote:
I'm thinking about having tiny (50x50?) thumbnails of images/albums along the right or bottom of the map. I like that idea. Thanks |
|
LarryDoliver
Joined: 2003-12-31
Posts: 35 |
![]() |
swordfish wrote:
done. check it out at http://tautologous.com/gallery2/travel and the new zip file http://tautologous.com/map.zip |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
LarryDoliver, i guess i'm repeating myself, but this rocks could you please add it to the themes list on: if you haven't already done so, you can register on codex.gallery2.org an account and then you can edit the page. |
|
swordfish
![]()
Joined: 2004-10-01
Posts: 388 |
![]() |
Yea, very cool! Think I'd prefer some white space in between the tiny thumbs or some type of mini |
|
HorsePunchKid
![]()
Joined: 2005-05-04
Posts: 89 |
![]() |
I've gotten a module-based (as opposed to theme-based) version working. You can see the result on my gallery. It was quite challenging figuring out how to perform many of the basic tasks with essentially no documentation, but it was very rewarding. "find modules -name \*.class | xargs grep -li 'a_function('" will get you a long way in figuring how things work, it turns out. ;-) If anyone is interested, I can clean up my code a bit and zip it up. The only configuration required is to go into the Site Admin page and enter your Google Map API key. Just attach GPS coordinates to your photos or albums as with Larry's version. The only thing I haven't figured out how to do automatically is stick the rewrite rules into the .htaccess to make the friendly URL work. It's pretty easy to do manually, though. |
|
HorsePunchKid
![]()
Joined: 2005-05-04
Posts: 89 |
![]() |
Another thing I haven't figured out is how to get my "ShowMap" template to be able to insert content into the page's head tag. For example, there are a few CSS rules and a script tag that should really be there instead of in the body. If anyone can shed some light on this, I would greatly appreciate it! |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
@inserting <head> content: |
|
samkuhn2
Joined: 2004-04-13
Posts: 60 |
![]() |
Hey HorsepunchKid, anychance you would implement thsi feature in your module? |
|