Google Maps + Gallery
peterm
Joined: 2004-12-13
Posts: 39 |
Posted: Fri, 2005-07-08 03:19 |
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. |
|
Posts: 32509
someone would have to write such a G2 module, but yes, it's possible.
the devs of G2 are very busy these days. but if you or someone else is interested in writing such a G2 module, we'd gladly guide you through and answer your questions.
Posts: 47
This is indeed a great idea!
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!
Posts: 21
This would be great, someone please do this.
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:
(edited broken link out. try this one instead) (standalone php page - but hey, it's a start)
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?
* I want to only show things on the map that have GPS data in my custom field. Is there smarty/gallery logic to determine this?
* I want to show all albums (and only albums for my needs) in one page - not just those that are sub-albums of the current album (following me?). Know how to do this?
thanks...
Posts: 35
Got it working!!!
http://tautologous.com/gallery2/travel/
This takes two custom fields:
GoogleMapKey (which is assigned to a folder)
GPS (assigned to photos in the folder mentioned above)
kinda clunky, and not 100% what I wanted (to be able to see children and grandchildren items), but it works.
album file attached.
Posts: 16504
LarryDoliver, there's no attachment to your post. Try zipping it.
Posts: 8601
LarryDoliver, super cool!
Posts: 21
That's the shizzle Larrycan you gives a module? or some way to use this?
Thanks in advance.
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.
Posts: 35
how 'bout now...
Posts: 35
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...
(edit) actually - that seems to be working too. Kewl
Posts: 16504
LarryDoliver, that is sooo damn cool. Thank you for sharing!!!
Posts: 16504
I've added your mod to the User Contribution page, http://codex.gallery2.org/index.php/Gallery2:UserContributions#Mods.2FPatches
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..
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)
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.
Thanks for the hard work.
Posts: 35
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):
a) copy the matrix theme folder and call the new one 'map' (clever name, right?)
b) edit theme.inc and change all 'matrix' references to 'map'
c) copy the file I attached a couple posts back in this thread into a folder called 'local' in the templates folder
(me thinks that's it...)
then (2):
a)turn on the customfield module, add two custom fields:
*GoogleMapKey (which is assigned to an album
*GPS (assigned to photos and sub-albums in the folder mentioned above)
b)Go sign up with google to get a mapkey for each album you want to map and stick this in the album's GoogleMapKey custom field
c)Add GPS data to the images' custom fields: "Longitude,Latidude" - no quotes
d)Turn on the map theme a let 'er rip
that's how I remember it. Let me know if it works, and post a link, too...
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:
Internet Explorer cannot open the internet site {url}
Opertion aborted.
This also happens on your site
Posts: 60
Nice work Larry!
I have a few requests/suggestions.
1) Have different pushpin icons for albums vs. photos
2) Have different colors available for album/photo pushpins
3) When an album pushpin is clicked on, have gmaps zoom to display pushpins for all the items within that gallery (photos and albums). A given album could be assigned a master pushpin color.
4) Allow toggle display of all items in a given gmap view (the pushpins would be color coded to allow different albums of photos to be distinguished)
Posts: 4
Everything you need to know about google maps, including the pinpoints and colours, is here.
http://maps.google.com/apis/
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.
I went into the album I was interested in using, edited that specific album, an album custom field of GoogleMapKey and dropped the key into the custom field area.
When I attempt to use the above url, I get the key is registered for a different url. 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.
Posts: 35
I registered keys for things like "http://tautologous.com/gallery2/travel"
Posts: 35
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...
Posts: 8
Am I the only one with problems when viewing with IE 6? In IE it's impossible to see the page
Posts: 35
No - you are not alone. Can you get to this site (another, very slick, google map photo implementation)
Posts: 8
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
Posts: 35
Doesn't seem to be a URL_rewrite issue (it's broken in both cases)
Might be a 'cross-site scripting' security thing? I tried a few settings on a windows machine's IE Security options, but that didn't help. I'm not sure how to really test this, though. My page needs to download javascript and images from various google.com domains - but all google maps sites do that as well...
kinda stuck here...
I get the same apache requests from both IE and firefox (from the same machine):
IE:
firefox:
The only difference seems to be the order...
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")
Posts: 16504
Looks like the script issue may just be a typo:
http://validator.w3.org/check?uri=http%3A%2F%2Ftautologous.com%2Fgallery2%2Ftravel
You have a script tag starting and never ending in the document on line 12
Here's the CSS validator results too:
http://jigsaw.w3.org/css-validator/validator?uri=http%3A%2F%2Ftautologous.com%2Fgallery2%2Ftravel&usermedium=all
Probably get something better once the page validates to XHTML strict.
Posts: 8
Yeah it seems to work in IE 6 now. But now I get a javascript error:
Not perfect yet but it's getting better every time :D
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
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.
I tried viewing your site (above url) but got a G2 error debug page.
Yea, this implementation is awesome --> http://www.panoramio.com/
Thanks!
Posts: 21
Swordfish this is what Larry posted before:
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):
a) copy the matrix theme folder and call the new one 'map' (clever name, right?)
b) edit theme.inc and change all 'matrix' references to 'map'
c) copy the file I attached a couple posts back in this thread into a folder called 'local' in the templates folder
(me thinks that's it...)
then (2):
a)turn on the customfield module, add two custom fields:
*GoogleMapKey (which is assigned to an album
*GPS (assigned to photos and sub-albums in the folder mentioned above)
b)Go sign up with google to get a mapkey for each album you want to map and stick this in the album's GoogleMapKey custom field
c)Add GPS data to the images' custom fields: "Longitude,Latidude" - no quotes
d)Turn on the map theme a let 'er rip
that's how I remember it. Let me know if it works, and post a link, too...
Hope that helps.
Posts: 388
hey f33dback, Thanks for the details!! I'll give this a shot.
Posts: 32
http://www.google.com/apis/maps/signup.html
that's the signup page where you enter your url. the key generated at signup isn't valid [thus, you need to make a new one for each dir on your server].
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
Here's the new theme. http://tautologous.com/map.zip (might not stay here for ever...)
How do you post attachments in the new forum?
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.
--
http://severinghaus.org/gallery2/
Posts: 89
I should mention that my map is based on LarryDoliver's code. Thanks so much for that, Larry!
--
http://severinghaus.org/gallery2/
Posts: 35
This code iterates through all children looking for nonempty custom fields called GPS...
Is that what you're looking for?
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.
--
http://severinghaus.org/gallery2/
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...
Posts: 388
hey Larry,
I just checked out your site and must say this is too cool! I've gotta make some time and do this myself.
Awesome job!! I have my G2 (using Matrix theme) embedded with WordPress so do you think it would be
possible using your Map theme? I'm assuming some css hacking would be required.
I like that idea.
Thanks
Posts: 35
done. check it out at http://tautologous.com/gallery2/travel and the new zip file http://tautologous.com/map.zip
Posts: 32509
LarryDoliver, i guess i'm repeating myself, but this rocks
could you please add it to the themes list on:
http://codex.gallery2.org/index.php/Gallery2:UserContributions#Themes
if you haven't already done so, you can register on codex.gallery2.org an account and then you can edit the page.
Posts: 388
Yea, very cool! Think I'd prefer some white space in between the tiny thumbs or some type of mini
frame border but, yea this rocks!! Thanks for the updated map theme.
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.
--
http://severinghaus.org/gallery/
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!
--
http://severinghaus.org/gallery/
Posts: 32509
@inserting <head> content:
a) if your module offers the map as a block -> Preloads.inc (e.g. see imageblock) (and then use b))
b) if your module offers the map as a view -> $template->head('modules/slideshow/templates/Header.tpl'); see modules/slideshow/Slideshow.inc
obvivously you do it with a view.
Posts: 60
Hey HorsepunchKid, anychance you would implement thsi feature in your module?
When an album pushpin is clicked on, have gmaps zoom to display pushpins for all the items within that gallery (photos and albums). A given album could be assigned a master pushpin color. If there are children items with GPS coords, just display the thumbnail popup.