Pages (2): 1 2   
Member
Member
wibbi   17-03-2018, 17:03
#1

How can I create a photomap page with the zpOpenStreetMap() plugin that shows all photos of all albums?

Administrator
Administrator
acrylian   17-03-2018, 18:28
#2

Use the class directly and pass an array of all geodata you want to the $geodata parameter of the constructor. The constructor doc has info how that array has to be setup.

Generally the plugin is setup so you can use it for any kind of geodata, e.g. it must not even use albums/images from Zenphoto itself.

Member
Member
wibbi   17-03-2018, 19:36
#3

I have never done anything with classes. This is absolutely new for me.

First question: I do not understand how I get to the images of the subfolders.

Administrator
Administrator
acrylian   17-03-2018, 20:52
#4

The core of Zenphoto is class based. You basically have to loop through all albums recursively via the gallery class and then album class on each.

You could also get all album names from the database directly but you still need to create album objects and check on them as you otherwise will bypass publish status or protection which is inherited from parents.

Basics of the object model behind everything:
http://www.zenphoto.org/news/zenphotos-object-model-framework/

Member
Member
wibbi   17-03-2018, 21:45
#5

I have not found a function to grab all image filenames in subfolders from a parent folder.

I will rewrite the function getAlbumGeodata($album) { with (not finally, in progress)

[code]$All_SubAlbum_IDs = getAllSubAlbumIDs();
$images = array();
for (&#36;i = 1; &#36;i < count(&#36;All_SubAlbum_IDs); &#36;i++) {
&#36;result = query("SELECT filename FROM " . prefix('images') . " WHERE albumid = '" . &#36;All_SubAlbum_IDs[&#36;i]["id"] . "'");
while (&#36;row = db_fetch_assoc(&#36;result)) {
array_push(&#36;images, &#36;row["filename"]);
}
}[/code]

And than i can display the zpOpenStreetMap() in parent folders, i think. But for today is enough.

Administrator
Administrator
acrylian   17-03-2018, 23:00
#6

I have not found a function to grab all image filenames in subfolders from a parent folder.

Create an album object for an album and get its images via the appropiate method getImages() is the way to do that. Again you have to do this recursively for further levels by using the getAlbums() method of the album object.

Note that you your code does not check for the publish state of the images and getAllSubAlbumIDs() does not check for protection, publish state or if this is a user's album either. You have to use the objects and the related methods as well. Use the function getItemByID() to get an oject from those ids.

Again you should extend the plugin class either theme based or via an additional plugin and modify any method of the original class you need different.

Member
Member
wibbi   18-03-2018, 13:19
#7

I understood that differently. In a parent album, where there are only sub albums, getAlbums() will deliver the subalbums. In a parent album where there are only subalbums, getImages() = NULL. Everything always works only on the current album. There is no function getImages('any-album'), but only getImages('current-album').

Create an album object for an album

How does it work?

How does the getAlbumGeodata() function check whether the images are published or locked?
http://docs.zenphoto.org/source-function-getAlbumGeodata.html#278-295

getImages() is not in the documentation.

Administrator
Administrator
acrylian   18-03-2018, 13:45
#8

An album can have both images and sub albums.

I understood that differently. In a parent album, where there are only sub albums, getAlbums() will deliver the subalbums. In a parent album where there are only subalbums, getImages() = NULL. Everything always works only on the current album.
Yes, but I am not talking about the standard template functions that are procedural.

There is no function getImages('any-album'), but only getImages('current-album').
No, you have to use the object model for that which then provides methods to do that.
Please don't confuse procedural general template functions with class methods. There are sometimes similar named in both.

The article I linked above explains how the object model works with examples. If object orientation in general is new to you please see here:
http://php.net/manual/en/language.oop5.php

How does the getAlbumGeodata() function check whether the images are published or locked?

It doesn't itself. Basically the functions/class methods who deliver the data do that and only deliver what is allowed.

Member
Member
wibbi   18-03-2018, 20:24
#9

I hang. How do I get the latitude and longitude of an image?
&#36;imageobject["data"]->EXIFGPSLatitude
&#36;imageobject->getImageGeodata()
getImageGeodata(&#36;imageobject)
&#36;imageobject->getGeoCoord()
getGeoCoord(&#36;imageobject)
don't work by me.

Administrator
Administrator
acrylian   18-03-2018, 21:04
#10

No, because it does not work that way. You cannot use class methods directy…

This should work:

Create an image object of image.jpg in album album;

&#36;albobj = newAlbum('album');

&#36;imgobj = newImage(&#36;albobj, 'image.jpg');
&#36;geodata= array(
   array(
     'lat' => &#36;imgobj->get('EXIFGPSLatitude'),
    'long' => &#36;imgobj->get('EXIFGPSLongitude'),
     'title' => &#36;imgobj->getTItle(),
    'desc' => &#36;imgobj->getDesc(),
     'thumb' => '' // an [img][/img] for example for a thumb or whatever
    )
   );

Add arrays within the array for every further image.

Then either setup a map object:

&#36;map = new zpOpenStreetMap(&#36;geodata); 
&#36;map->printMap();

Or use the procedural wrapper:
printOpenStreetMap(&#36;geodata);

This will get you a map outside any album/image context since you wanted all images. Be aware that hundreds or thousand markers will make the map probably quite slow.

Member
Member
wibbi   18-03-2018, 21:26
#11

Hey, many thanks.

I would never have thought of the solution.
&#36;imgobj->get('EXIFGPSLatitude')

For title and desc only one string is needed?
At thumb HTML img tag must be used?

What happens if I leave title and desc? I do not want to show both.

Administrator
Administrator
acrylian   18-03-2018, 21:32
#12

&#36;imgobj->get('some field') is the core functionality of the root class. But use appropiate methods if available as they might do some extra stuff.

At thumb HTML img tag must be used?
You can use any html here. Just an image or a link wrapping an image or else (be aware this is used within JS so test complicated html beforehand).

Only lat/long is required in that array, leave blank what else you don't need.

Member
Member
wibbi   18-03-2018, 22:12
#13

...don't work.

this is the &#36;geodata PHP array var_dump():
[code]array(255) {
[1]=>
array(6) {
["lat"]=>
string(15) "12.345"
["long"]=>
string(15) "12.345"
["title"]=>
string(0) ""
["desc"]=>
string(0) ""
["thumb"]=>
string(0) ""
["current"]=>
string(1) "0"
}
...[/code]

This is in the HTML source code:
[code]var geodata = new Array();
geodata[0] = {
lat : "12.345",
long : "12.345",
title : "",
desc : "",
thumb : "",
current : "0"
}; geodata[1] = {
lat : "12.678",
long : "12.678",
title : "",
desc : "",
thumb : "",
current : "0"
}; geodata[2] = {
...[/code]

printOpenStreetMap(&#36;geodata);
or
[code]&#36;map = new zpOpenStreetMap(&#36;geodata);
&#36;map->printMap();[/code]

display no map, only a grey box.

Member
Member
wibbi   19-03-2018, 08:40
#14

My mistake. I started the array &#36;geodata with 1. Why? I forgot. With 0 it works.

Member
Member
wibbi   19-03-2018, 08:47
#15

The test was in /themes/mybasic/album.php.
Now it should work in /themes/mybasic/index.php.
Problem: getAllAlbums() don't work in /themes/mybasic/index.php.

Administrator
Administrator
acrylian   19-03-2018, 10:25
#16

Of course not, it its either dependend on the current album or you have to pass one.

To get all albums try this:

&#36;toplevelalbums = &#36;_zp_gallery->getAlbums(0);
&#36;albumlist = array();
foreach(&#36;toplevelalbums as &#36;album) {
 &#36;obj = newAlbum(&#36;album);
&#36;albumlist[] = &#36;obj->getID();
//  getAllAccessibleAlbums() should assign to &#36;albumlist, it assigns IDs
// only so you need to create objects later again to get their images - other than 
// getAllAlbums() this does check for access etc.
 getAllAccessibleAlbums(&#36;obj); 
}

This is untested code, roughly written down rather offhand.

Member
Member
vincent3569   19-03-2018, 11:51
#17

hi,
I wrote a tip to have a map of all geotagued pictures with googlemap plugin: http://www.vincentbourganel.fr/news/map-of-geo-localized-pictures/
my map works with this:http://www.vincentbourganel.fr/pages/map/

maybe, could be used with zpOpenStreetMap plugin.

Administrator
Administrator
acrylian   19-03-2018, 12:03
#18

Using a dynamic album is of course a way as well and should work.

Member
Member
wibbi   19-03-2018, 14:24
#19

Thank you vincent, but I did not want to use Google Maps anymore, but OSM (and preferably with OpenLayer instead of Leaflet).

It now works with the OSM plugin. An overview in the index.php, an overview in parent albums in the album.php. But there is a problem. As soon as I want to display thumbs in the index.php OSM, there is server timeout. It loads too long. Even larger parent albums and sub-albums load very long. This blocks the page.
Can you speed up the loading?

Administrator
Administrator
acrylian   19-03-2018, 14:54
#20

You have to go through a lot of data and you have to load a lot of thumbs that also need to be generated (if you haven't precached them).
I recommend that you try Vincen'ts trick with the dynamic album. It might indeed be faster.

and preferably with OpenLayer instead of Leaflet

You can of course create your own custom plugin to use that. I choose LeafletJS because I like it better.

Pages (2): 1 2   
  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.