From our sponsor: Turn your vision into reality on WordPress using Divi's advanced builder
This multi-level map based image gallery makes it possible to show images related to their location. The first level indicates the location of the places where each one has a set of images, and the second level shows each single image and its location. Using Google Maps, we’ll have the location shown on the left side while the images of a location are shown on the right. The images can be viewed in medium size mode or in full lightbox-like mode. The map has a fullscreen option which will show the thumbnails of the images in their location.
How it works
The locations for the images are saved in the album.xml file which has the following stucture:
<album> <name>Thailand 2011</name> <description>Some description</description> <places> ... </places> </album>
Inside of the places, we’ll have the information of each place with its name and location and all the single photos in that place:
<place> <name>Bangkok</name> <location> <lat>13.696693336737654</lat> <lng>100.57159423828125</lng> </location> <photos> <photo> <thumb>photos/Bangkok/thumbs/1.jpg</thumb> <source>photos/Bangkok/1.jpg</source> <description>Some description</description> <location> <lat>13.710035342476681</lat> <lng>100.52043914794922</lng> </location> </photo> <photo> ... </photo> </photos> </place>
Besides the path to its thumbnail and the full image, every photo has a location in latitude and longitude as well.
Note, that we are using some PHP here in order to load and retrieve the XML data, so you’ll need a server environment to run this.
Initially, a map with all the places is shown:
In our example it is Bangkok, Phuket and Myeik. In the bar under the map and the preview area, we will have the name and the description of the whole album. In this stage we can already go fullscreen in order to see the full map with the places.
Back in the normal mode, when choosing a place, all the images of that place will show on the right side while we zoom the map in on the left side. As you can see, whenever you hover over a photo, you will see its location on the map and vice versa:
When clicking on a thumbnail or the camera icon on the map, we open the preview for the images, through which we can also navigate:
Clicking on the zoom icon of the preview image will open the large lightbox-like view of the full image:
When we are in the second level and open the fullscreen mode, we can see the thumbnails in the map:
Hope you find it useful, feedback is welcome!