geograph-project / Leaflet.GeographPhotos

Plots Geograph Photos on a Leaflet Map!
MIT License
17 stars 7 forks source link

Leaflet.GeographPhotos

Plots Geograph Photos on a Leaflet Map!

Extends the most excellent (and very tiny!) Leaflet.Photo plugin, http://blog.mastermaps.com/2014/08/showing-geotagged-photos-on-leaflet-map.html but intergrates calling the Geograph API to load photos. Including dynamically loading more as zoom the map.

Please contact Geograph before using, you also need a API key https://www.geograph.org.uk/help/api

Note: This plugin is heavily inspired by the demos from Leaflet.Photo, and as such uses its image popup styling. as such have moved the leaflet-popup-photo CSS class from Leaflet.Photo/examples/css/map.css, to Leaflet.Photo/Leaflet.Photo.css, so this project can just import one .css file

Demo

https://www.geograph.org/leaflet/Leaflet.GeographPhotos/GeographPhotos-example.html

Prerequisites:

Optional: (can also display a layer of dots highlighting where photos are located)

Clearly inspired by and draws ideas from:

See Also

Options

as extends BOTH Leaflet.Photo and Leaflet.markercluster, most options from those plugins can be used too. For example:

NOTE: PLEASE don't make maxClusterRadius less than about 60, as it can load lots of thumbnails!

Use

CSS:

    <link href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.4/leaflet.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="https://unpkg.com/leaflet.markercluster@1.4.1/dist/MarkerCluster.css" />
    <link rel="stylesheet" href="https://github.com/geograph-project/Leaflet.GeographPhotos/blob/master/Leaflet.Photo/Leaflet.Photo.css" />

JS (best loaded AFTER leaflet core):

    <script src="https://github.com/geograph-project/Leaflet.GeographPhotos/raw/master/Leaflet.Photo/examples/lib/reqwest.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.4/leaflet-src.js"></script>
    <script src="https://unpkg.com/leaflet.markercluster@1.4.1/dist/leaflet.markercluster.js"></script>
    <script src="https://github.com/geograph-project/Leaflet.GeographPhotos/raw/master/Leaflet.Photo/Leaflet.Photo.js"></script>
    <script src="https://github.com/geograph-project/Leaflet.GeographPhotos/raw/master/Leaflet.GeographPhotos.js"></script>

And add it to map...

    var gph = L.geographPhotos({api_key:'enter-your-key-here', autoZoomOnAdd: true, query:'canal'}).addTo(map);

See the example html for fuller example, as well as loading for other projects