]> git.mxchange.org Git - friendica-addons.git/blob - openstreetmap/openstreetmap.js
Merge pull request #166 from annando/master
[friendica-addons.git] / openstreetmap / openstreetmap.js
1 var toolserver = 'http://toolserver.org/~kolossos/openlayers/kml-on-ol.php';\r
2 var startTag = '<iframe class="osmFrame" style="width: 100%; height: 350px; clear: both;" src="'+ toolserver + '?lang=de&amp;uselang=de&amp;params=';\r
3 var endTag = '"></iframe>';\r
4 \r
5 jQuery(document).ready(function($) {\r
6 \r
7         $('.wall-item-content-wrapper').each(function(index) {\r
8                 var link = $(this).find('.wall-item-location .OSMMapLink');\r
9                 link.toggle(addIframe, removeIframe);\r
10         });\r
11 });\r
12 \r
13 function addIframe(ev) {\r
14         var coordinate = $(ev.target).attr('title');\r
15 \r
16         var newTag = startTag + convertCoordinateString(coordinate) + endTag;\r
17         $(ev.target).parents('.wall-item-content-wrapper').append(newTag);\r
18 }\r
19 \r
20 function removeIframe(ev) {\r
21         $(ev.target).parents('.wall-item-content-wrapper').find('iframe').remove();\r
22 \r
23 }\r
24 \r
25 function convertCoordinateString(coordinate) {\r
26         var locstring = coordinate.split(' ');\r
27         var northSouth;\r
28         var westEast;\r
29 \r
30         if (locstring[0] < 0) {\r
31                 northSouth = '_S_';\r
32         }else{\r
33                 northSouth = '_N_';\r
34         }\r
35         if (locstring[1] < 0) {\r
36                 westEast = '_W';\r
37         }else{\r
38                 westEast = '_E';\r
39         }\r
40         return Math.abs(locstring[0]) + northSouth + Math.abs(locstring[1]) + westEast;\r
41 }