📜 ⬆️ ⬇️

Geotagging: no single cards

image
On the Internet, the reception of a map of the place where the photo was taken is already quite widespread. In practice, this is implemented in two ways:
  1. Just indicating the place on the map, for example, as it is done on Flickr or using the GeoPress plugin for Wordpress
  2. Extraction of coordinates from the EXIF ​​of the photo - if they are there
The second method, of course, is much more “beautiful” and more correct - but somewhat more complicated technically. However, I will not consider how to add coordinates to EXIF ​​- but I’ll tell you how to use them.
For a long time, a very long time, an idea tormented me - I don't want to show a map. That is, the map is good, but not all. I want to tell the visitor in a human language: the photo was taken in such and such a city at such an address. Well, I wanted to do this for a long time, and finally I got ready.

As an "experimental pig", I took, of course, my own photoblog - hack, so full. A little bit about how it is organized:
  1. At the very "bottom" of the hierarchy is (well, does not lie the same!) Wordpress 2.7
  2. This Wordpress is based on the Yet Another Photoblog plugin , which turns a blog into a real photoblog.
  3. But on YAPB, in turn, the theme of Reflection , globally modified by the file (almost beyond recognition) is spinning
Among the advantages provided by YAPB, one of the most important for developers is that exactly one picture is always associated with a post, and you can easily get it EXIF. Therefore, everything else was a matter of technique.

I wrote a plug-in for YAPB (yes, a plug-in for a plug-in), which took the coordinates (which are for some reason recorded in EXIF ​​in degrees-minutes-seconds), converted them to WGS84, and then transferred everything to the client who did everything the rest (using, respectively, JavaScript). Why so hard? First of all, because the Google Maps API is ultimately used, and this has to be done on the client. Actually, each page breeds two API calls - one to generate a map, and the other to reverse geocoding coordinates. Actually, the result of this reverse geocoding is displayed as an address. How it all looks live can be viewed, for example, here or here . It is important to note that if there are no coordinates in the photo, there will be no magic, there will be no map and the address will not appear - so the loading of the photo is always preceded by the process of putting coordinates on them (however, it is extremely automated); In addition, the address is determined with the accuracy that is available to the supplier of Google's geodata (that is, if the photo was taken in an open steppe a hundred kilometers from the nearest settlement, there will be no miracle and you will get the name of the road at best).

In principle, I am absolutely ready to share all these developments, but ... the code is so terrible that I am just ashamed to upload it. Perhaps after some time I will brush it and draw it in the form of a normal plug-in - if there is interest in this. Wherefore I take my leave - and good shots to you!

')

Source: https://habr.com/ru/post/50517/


All Articles