Writing a new module: integration with google maps

missoni

Joined: 2013-09-06
Posts: 13
Posted: Fri, 2013-09-06 15:17

Hey guys!
I enjoy Gallery3, it's an amazing engine and even though it lacks the functionality I need at the moment, I am ready to enlarge the module database by creating my own module. For this, I need some help from the experts.

I am new to Gallery3, having used the old Gallery2 engine once, but I have never done any programming for it. Now I need to write a custom module and before I set off programming I wanted to check with the community that my understanding of module structure is right.

I want to connect a custom Google map to my gallery. I use Gallery 3.0.9. gmaps module does not seem to work or be supported any more and since there is no other similar module, I guess I will have to write my own.

Idea:
- every image will have GPS coordinates:
* read GPS coordinates from EXIF tags, or if not available:
* show a form with a map and allow the user to place the photo on the map during upload
- create a global map, on which all images wil be shown
* hovering over pin will display a preview of the photo
* clicking on the pin will open the photo page in the gallery
- for each image, show a small Google map preview on the photo page with a link to the global map
- enable editing GPS position of the image in the edit menu on the photo page

Implementation sketch:
- create a new table in the database: gallery_gps_coords: {image_id (image_id=gallery_items.id), lat, lng}
- hook onto add_photos_form_complete event and show add_gps_coords view
- hook onto item_edit_form_completed event and show edit_gps_coords view
- in the side panel on the photo page display a small map preview centered on the pin
- create add_gps_coords, edit_gps_coords & display_gps_coords views

Is my logic so far correct? I would be grateful for any help and suggestion, since this is my first time programming a module for Gallery3.

Thanks in advance!
Pavlo

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2013-09-06 18:08

http://codex.galleryproject.org/Gallery3:Modules:exif_gps
Has most of what you are after. The hardest parts are done.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
missoni

Joined: 2013-09-06
Posts: 13
Posted: Fri, 2013-09-06 21:09

Hey floridave,
thanks for your fast reply! Indeed, exif_gps does half of what I need. The rest can be programmed by myself. Especially, I want to rewrite item_edit_form event so that the user can select picture position by clicking on a small map, not by entering exact coordinates as strings. I can't quite figure out how to insert a custom <div> into the existing php code:

static function item_edit_form($item, $form) {
// Allow users to set / edit the GPS coordinates associated with the current item.
$record = ORM::factory("exif_coordinate")->where("item_id", "=", $item->id)->find();
$gpsdata = $form->edit_item->group("gps_data")->label("GPS Data");
..
$gpsdata->input("latitude")->label(t("Latitude"));
$gpsdata->input("longitude")->label(t("Longitude"));
}

I want to replace the last two lines with something like:

<div id="map-canvas" class="edit_gps_coords_map_canvas">
</div>

and add a scripting line to call map initializer to the page header. Is this possible?

Thank you in advance!
Pavlo

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sat, 2013-09-07 15:22

I don't know much about the form generator of Kohana. What I would do is use jquery to remove the 2 inputs ( or leave them there ) and append or preppend the input with your div. Or replaceWith or something similar.
If you need some help with the Jquery part I can do a bit of digging finding a few examples.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
xeta

Joined: 2011-11-24
Posts: 42
Posted: Sun, 2013-09-08 14:45

Did you already go through this threat http://galleryproject.org/node/94762

Something could be helpful for your project.

The actual module seems not to be supported anymore but in the end i figured out how to get it back to work (last posts of certain threat)

www.xeta.at

 
missoni

Joined: 2013-09-06
Posts: 13
Posted: Sun, 2013-09-08 20:40

Thanks for the fast replies!

floridave wrote:
If you need some help with the Jquery part I can do a bit of digging finding a few examples.

If you could help we with an example, that would be great! I want to add a div displaying a small map so that the user can click on the map & populate lat&lng fields automatically. I am otherwise absolutely unfamiliar with Kohana framework.

Can I activate this dialog after image upload is finished when the EXIF tags have already been parsed?

Quote:
Did you already go through this threat http://galleryproject.org/node/94762

Thanks for the link! Unfortunately none of the suggestions there can really help me here.

Thanks in advance for any help!