{"id":249,"date":"2009-01-04T15:53:11","date_gmt":"2009-01-04T13:53:11","guid":{"rendered":"http:\/\/www.gatellier.be\/blog\/?p=249"},"modified":"2009-04-18T15:57:29","modified_gmt":"2009-04-18T13:57:29","slug":"geotagging-bookmarklet","status":"publish","type":"post","link":"https:\/\/gatellier.be\/blog\/geotagging-bookmarklet\/","title":{"rendered":"Geotagging Bookmarklet"},"content":{"rendered":"<p>ou I CAN HAZ GEOTAGZ?<\/p>\n<h2>Status actuel de la g\u00e9olocalisation&nbsp;:<\/h2>\n<ul>\n<li>Le <a href=\"\/\/www.w3.org\/2008\/geolocation\/\" hreflang=\"en\">Groupe de Travail du W3C sur la g\u00e9olocalisation<\/a> est en place depuis peu, avec pour but de mettre sur pied des recommandations pour la fin de l&#8217;ann\u00e9e.<\/li>\n<li><a href=\"https:\/\/developer.mozilla.org\/En\/Using_geolocation\" hreflang=\"en\">Firefox 3.1 promet<\/a> l&#8217;impl\u00e9mentation d&#8217;une <abbr title=\"Application Programming Interface\" lang=\"en\">API<\/abbr> de g\u00e9olocalisation (pas encore de tests concluants sur la v3.1b2).<\/li>\n<li>Une s\u00e9rie de providers (tels <a href=\"\/\/dev3.maxmind.com\/app\/javascript_city\" hreflang=\"en\" lang=\"en\">MaxMind<\/a>) fournissent des services de conversion d&#8217;adresse <abbr title=\"Internet Protocol\">ip<\/abbr> vers un pays ou une adresse<\/li>\n<li>L&#8217;<a href=\"\/\/loki.com\/download\" hreflang=\"en\">extension Firefox Loki<\/a> permet une localisation pr\u00e9cise sur base de la triangulation des signaux des routeurs wifi alentours.<\/li>\n<li>L&#8217;<a href=\"\/\/labs.mozilla.com\/2008\/10\/introducing-geode\/\" hreflang=\"en\">extension Firefox Geode<\/a> promet d&#8217;employer les futures sp\u00e9cifications (<code>navigator.geolocation.getCurrentPosition()<\/code>)<\/li>\n<li>Google Gears a aussi une <a href=\"\/\/code.google.com\/apis\/gears\/api_geolocation.html\" hreflang=\"en\">API de g\u00e9olocalisation<\/a><\/li>\n<li><a href=\"\/\/code.google.com\/apis\/ajax\/documentation\/#ClientLocation\" hreflang=\"en\">Google JSAPI<\/a> (qui permet d&#8217;ajouter dans vos sites les librairies JavaScript les plus employ\u00e9es) a des m\u00e9thodes pour retrouver la position du visiteur.<\/li>\n<li><a href=\"\/\/blog.brightkite.com\/2008\/05\/02\/new-features-georss-around-me-radius-nearby-notifications-and-more\/\" hreflang=\"en\">BrightKite permet de Twitter et g\u00e9otagguer<\/a> directement les photos prises avec son iPhone<\/li>\n<\/ul>\n<h2>Geotag bookmarklet<\/h2>\n<p>Via les sp\u00e9cifications disponibles et m\u00e9thodes les plus faciles, je viens donc d&#8217;\u00e9crire un bookmarklet qui rajoute votre position g\u00e9ographique dans n&#8217;importe quel page web.<\/p>\n<p><strong><a style=\"padding:5px;border:1px solid #4960A3\" href='javascript:var%20GT%3D%28function%28%29%7Bvar%20c%3D4%2Cb%3D%22undefined%22%2Cf%3Ddocument%3Bvar%20e%3Dfunction%28h%2Cg%29%7Bvar%20d%3DMath.pow%2810%2Cg%29%3Breturn%20Math.round%28h*d%29\/d%7D%3Bvar%20a%3Dfunction%28g%29%7Bvar%20d%3Df.getElementsByTagName%28%22textarea%22%29%5B0%5D%3Bif%28d.value.indexOf%28%22%23geo%22%29%3C0%29%7Bd.value+%3D%22%23geo%3A%22+e%28g.latitude%2Cc%29+%22%2C%22+e%28g.longitude%2Cc%29%7D%7D%3Bthis.getLocation%3Dfunction%28%29%7Bvar%20d%3Dgoogle.loader.ClientLocation%3Bif%28d%21%3D%3Dnull%29%7Ba%28d%29%7D%7D%3Bthis.tag%3Dfunction%28%29%7Bif%28typeof%28navigator.geolocation%29%21%3Db%29%7Bnavigator.geolocation.getCurrentPosition%28function%28g%29%7Ba%28g%29%7D%29%7Delse%7Bif%28typeof%28google%29%3D%3Db%29%7Bvar%20d%3Ddocument.createElement%28%22script%22%29%3Bd.src%3D%22http%3A\/\/www.google.com\/jsapi%3Fcallback%3DGT.getLocation%22%3Bf.getElementsByTagName%28%22body%22%29%5B0%5D.appendChild%28d%29%7D%7D%7D%3Breturn%7Btag%3Atag%2CgetLocation%3AgetLocation%7D%7D%29%28%29%3BGT.tag%28%29%3B'>GeoTag Bookmarket<\/a><\/strong><\/p>\n<p>Pour l&#8217;installer, il suffit de glisser d\u00e9poser le lien ci-dessus dans votre barre de favoris.<\/p>\n<p>En cliquant dessus, le bookmarket rajoutera votre position (s&#8217;il la trouve) au premier champ <code>textarea<\/code> de la page que vous visitez. Parfait pour Twitter.com<\/p>\n<h2>Le script de mon Geotag bookmarklet<\/h2>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nvar GT=(function(){\r\n\tvar P=4,u=&quot;undefined&quot;,d=document;\r\n\tvar format=function(n,c){\r\n\t\tvar m=Math.pow(10,c);\r\n\t\treturn Math.round(n*m)\/m;\r\n\t};\r\n\tvar addMarker=function (p){\r\n\t\tvar t=d.getElementsByTagName(&quot;textarea&quot;)&#x5B;0];\r\n\t\tif(t.value.indexOf(&quot;#geo&quot;)&lt;0){t.value+=&quot;#geo:&quot;+format(p.latitude,P)+&quot;,&quot;+format(p.longitude,P);}\r\n\t};\r\n\tthis.getLocation=function(){\r\n\t\tvar p=google.loader.ClientLocation;\r\n\t\tif (p!==null){addMarker(p);}\r\n\t};\r\n\tthis.tag=function(){\r\n\t\tif(typeof(navigator.geolocation)!=u){\r\n\t\t\t\/\/https:\/\/developer.mozilla.org\/En\/Using_geolocation || geode\r\n\t\t\tnavigator.geolocation.getCurrentPosition(function(p){addMarker(p);});\r\n\t\t} else {\r\n\t\t\t\/\/\/\/code.google.com\/apis\/ajax\/documentation\/#ClientLocation\r\n\t\t\tif (typeof(google)==u){\r\n\t\t\t\tvar jsapi=document.createElement(&quot;script&quot;);\r\n\t\t\t\tjsapi.src=&quot;\/\/www.google.com\/jsapi?callback=GT.getLocation&quot;;\r\n\t\t\t\td.getElementsByTagName(&quot;body&quot;)&#x5B;0].appendChild(jsapi);\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\treturn {tag:tag,getLocation:getLocation};\r\n})();\r\nGT.tag();\r\n<\/pre>\n<p>Mon script v\u00e9rifie si l&#8217;objet <code>navigator.geolocation<\/code> existe (donc, si c&#8217;est FF3.1b2 ou si Firefox a l&#8217;addon Geode install\u00e9), sinon, il utilisera les m\u00e9thodes fournies par le <a href=\"\/\/code.google.com\/apis\/ajax\/documentation\/#ClientLocation\" hreflang=\"en\">JSAPI de Google<\/a>.<\/p>\n<h3>Bugs connus&nbsp;:<\/h3>\n<ul>\n<li>Si vous passez par un server proxi pour vous connecter \u00e0 internet ou si simplement les services de g\u00e9olocalisation ne reconnaissent pas, aucun tag ne sera affich\u00e9.<\/li>\n<li>Internet Explorer 6 ne supporte pas les longs bookmarklets, je vous recommande donc d&#8217;installer un autre navigateur.<\/li>\n<li>La g\u00e9olocalisation avec Firefox 3.1 beta 2 ne marche pas encore super bien.<\/li>\n<li>Je limite la pr\u00e9cision \u00e0 quatre d\u00e9cimales.<\/li>\n<li>J&#8217;emploie le syst\u00e8me de g\u00e9otagging employ\u00e9 BrightKite (par soucis de bri\u00e8vet\u00e9 pour le status Twitter <code>#geo:&lt;lat&gt;,&lt;long&gt;<\/code>) et pas <a href=\"\/\/en.wikipedia.org\/wiki\/Geotagging#Geotagging_in_tag-based_systems\" hreflang=\"en\">celui recommand\u00e9 par Flickr<\/a> (<code>geo:lat=&lt;lat&gt;,geo:lon=&lt;long&gt;<\/code>)<\/li>\n<\/ul>\n<h3>Liens relatifs&nbsp;:<\/h3>\n<ul>\n<li>Le <a href=\"\/\/almaer.com\/whereareyou\/\" hreflang=\"en\">script de Dion Almaer<\/a> qui emploie aussi Google Gears (via <a href=\"\/\/ajaxian.com\/archives\/firefox-31-beta-geolocation-font-face-video-and-audio-xhr-and-tracemonkey\" hreflang=\"en\">Ajaxians<\/a>)<\/li>\n<li><a href=\"\/\/www.wired.com\/software\/webservices\/news\/2008\/12\/YE8_web?currentPage=2\" lang=\"en\">6 technologies de 2008 que vous devez utiliser maintenant<\/a> (dont la g\u00e9olocalisation) sur Wired<\/li>\n<li>Exemple de <a href=\"\/\/twitter.com\/ryanstewart\/status\/1055867917\" hreflang=\"en\">Tweet g\u00e9otaggu\u00e9<\/a> via BrightKite<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Via les sp\u00e9cifications disponibles et m\u00e9thodes les plus faciles, je viens donc d&#8217;\u00e9crire un bookmarklet qui rajoute votre position g\u00e9ographique dans n&#8217;importe quel page web.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[58,28,30,38,42,54,101,12],"tags":[175,107,109,106,105,182,108,181],"class_list":["post-249","post","type-post","status-publish","format-standard","hentry","category-extension","category-browsing","category-code","category-firefox","category-geotagging","category-javascript","category-twitter","category-utilitaire","tag-firefox","tag-gears","tag-geode","tag-geolocalisation","tag-geolocation","tag-geotagging","tag-google-api","tag-twitter"],"_links":{"self":[{"href":"https:\/\/gatellier.be\/blog\/wp-json\/wp\/v2\/posts\/249","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gatellier.be\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gatellier.be\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gatellier.be\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/gatellier.be\/blog\/wp-json\/wp\/v2\/comments?post=249"}],"version-history":[{"count":0,"href":"https:\/\/gatellier.be\/blog\/wp-json\/wp\/v2\/posts\/249\/revisions"}],"wp:attachment":[{"href":"https:\/\/gatellier.be\/blog\/wp-json\/wp\/v2\/media?parent=249"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gatellier.be\/blog\/wp-json\/wp\/v2\/categories?post=249"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gatellier.be\/blog\/wp-json\/wp\/v2\/tags?post=249"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}