{"id":2197,"date":"2012-06-02T12:34:12","date_gmt":"2012-06-02T11:34:12","guid":{"rendered":"http:\/\/flaven.fr\/?p=2197"},"modified":"2013-09-24T05:30:13","modified_gmt":"2013-09-24T03:30:13","slug":"google-maps-javascript-api-notions-de-base-de-la-google-maps-javascript-api-et-une-approche-sur-le-datajournalisme","status":"publish","type":"post","link":"https:\/\/flaven.fr\/2012\/06\/google-maps-javascript-api-notions-de-base-de-la-google-maps-javascript-api-et-une-approche-sur-le-datajournalisme\/","title":{"rendered":"Google Maps, JavaScript, API &#8211; Notions de base de la Google Maps JavaScript API et une approche sur le datajournalisme"},"content":{"rendered":"<p>\n<!--  Google Maps, JavaScript, API - Notions de base de la Google Maps JavaScript API et une approche sur le datajournalisme  --><br \/>\n<!--  datajournalism, datajournalisme, g\u00e9olocalisation,  Google Maps, JavaScript, API, \u00e9v\u00e9nement, ic\u00f4nes, ouverture, fermeture, Data journalism, data visualisation, google fusion tables, online map, texas tribune, The Guardian, the Telegraph  --><\/p>\n<p>Il existe de tr\u00e8s nombreux usages possibles de l&#8217;API Google Maps afin de faire des cartes personnalis\u00e9s notamment. Le plus \u00e9tourdissant dans cette personnalisation est, \u00e0 notre avis de lier, la quantit\u00e9 des r\u00e9f\u00e9rences \u00e0 la personnalisation des marqueurs en terme d&#8217;affichage.<!--more--> Id\u00e9alement, en cr\u00e9ant dynamiquement un fichier <code>json<\/code> contenant toutes les informations n\u00e9cessaires \u00e0 l&#8217;affichage des marqueurs personnalis\u00e9s, vous pouvez cr\u00e9er un aper\u00e7u d&#8217;informations g\u00e9olocalis\u00e9es tout \u00e0 fait int\u00e9ressant, ce qui vous fera toucher du doigt, les exp\u00e9rimentations de <code>datajournalisme<\/code> \u00e0 l&#8217;instar de ces exemples :<\/p>\n<ul>\n<li><a title=\"WikiLeaks Iraq war logs \u2013 every death mapped\" href=\"http:\/\/www.guardian.co.uk\/world\/datablog\/interactive\/2010\/oct\/23\/wikileaks-iraq-deaths-map\" target=\"_blank\">WikiLeaks Iraq war logs \u2013 every death mapped<\/a><\/li>\n<li><a title=\"Texas Tribune - Census 2010 interactive map \u2013 Texas population by race, hispanic origin\" href=\"http:\/\/www.texastribune.org\/library\/data\/census-2010\/\" target=\"_blank\">Texas Tribune &#8211; Census 2010 interactive map \u2013 Texas population by race, hispanic origin<\/a><\/li>\n<\/ul>\n<p><b>Une conf\u00e9rence s&#8217;est d&#8217;ailleurs \u00e0 Paris, tr\u00e8s r\u00e9cemment, Voir <a href=\"http:\/\/www.news-worldsummit.org\/\" target=\"_blank\">News2012 | #HacktheNewsroom<\/a> o\u00f9 il a \u00e9t\u00e9 sans beaucoup question de datajournalisme.<\/b><\/p>\n<p>Dans une cat\u00e9gorie, plus ludique que journalistique, c&#8217;est exactement ce principe que nous avons appliqu\u00e9 lors de la cr\u00e9ation de cette carte du style pour le site de Treets Looks, qui permet de <a href=\"http:\/\/www.treetslook.com\/style-map\/\" target=\"_blank\">visualiser tous les vid\u00e9os de street styles vid\u00e9o sur une carte du monde<\/a>.<\/p>\n<p>Tout ces interaction sont rendus possible gr\u00e2ce l&#8217;API JavaScript de Google Map. Cette API Javascript est pilot\u00e9 par les \u00e9v\u00e9nements dans le navigateur, ce qui signifie que l&#8217;API Javascript r\u00e9pond \u00e0 des interactions en g\u00e9n\u00e9rant des \u00e9v\u00e9nements.<br \/>\nC&#8217;est l\u00e0 aussi les principes en action que nous avons pouss\u00e9 tr\u00e8s loin avec <a href=\"http:\/\/www.3wdoc.com\/\" target=\"_blank\">l&#8217;API 3WDOC<\/a>, elle aussi en javascript mais revenons \u00e0 notre article.<\/p>\n<h2>Le jeu des capitales<\/h2>\n<p>On va placer ces 11 capitales europ\u00e9ennes sur une carte google \u00e0 l&#8217;aide des coordonn\u00e9es longitude et latitude. Cela donne \u00e0 la cr\u00e9ation d&#8217;un fichier <code>json<\/code> de ce type.<\/p>\n<ul>\n<li>Paris &#8211; Latitude : 48.8578058 &#8211; Longitude : 2.29463<\/li>\n<li>Berlin &#8211; Latitude : 52.519171 &#8211; Longitude : 13.4060912<\/li>\n<li>Madrid &#8211; Latitude : 40.4166909 &#8211; Longitude : -3.7003454<\/li>\n<li>Ath\u00e8nes &#8211; Latitude : 37.9753357 &#8211; Longitude : 23.7361497<\/li>\n<li>Rome &#8211; Latitude : 41.8905198 &#8211; Longitude : 12.4942486<\/li>\n<li>Londres &#8211; Latitude : 51.5081289 &#8211; Longitude : -0.128005<\/li>\n<li>Lisbonne &#8211; Latitude : 38.706932 &#8211; Longitude : -9.1356321<\/li>\n<li>Varsovie &#8211; Latitude : 52.2296756 &#8211; Longitude : 21.0122287<\/li>\n<li>Prague &#8211; Latitude : 50.0878114 &#8211; Longitude : 14.4204598<\/li>\n<li>Budapest &#8211; Latitude : 47.4984056 &#8211; Longitude : 19.0407578<\/li>\n<li>Copenhague &#8211; Latitude : 55.6760968 &#8211; Longitude : 12.5683371<\/li>\n<\/ul>\n<p><b>Le fichier json de source <code>le_jeu_des_capitales.json<\/code><\/b><\/p>\n<pre lang=\"javascript\">\r\n\t{\"markers\": [\r\n\t\t{\"lat\":48.8578058, \"lng\":2.29463, \"html\":\"Paris - Latitude : 48.8578058 - Longitude : 2.29463\"},\r\n\t\t{\"lat\":52.519171, \"lng\":13.4060912, \"html\":\"Berlin - Latitude : 52.519171 - Longitude : 13.4060912\"},\r\n\t\t{\"lat\":40.4166909, \"lng\":-3.7003454, \"html\":\"Madrid - Latitude : 40.4166909 - Longitude : -3.7003454\"},\r\n\t\t{\"lat\":37.9753357, \"lng\":23.7361497, \"html\":\"Ath\u00e8nes - Latitude : 37.9753357 - Longitude : 23.7361497\"},\r\n\t\t{\"lat\":37.9753357, \"lng\":23.7361497, \"html\":\"Ath\u00e8nes - Latitude : 37.9753357 - Longitude : 23.7361497\"},\r\n\t\t{\"lat\":41.8905198, \"lng\":12.4942486, \"html\":\"Rome - Latitude : 41.8905198 - Longitude : 12.4942486\"},\r\n\t\t{\"lat\":51.5081289, \"lng\":-0.128005, \"html\":\"Londres - Latitude : 51.5081289 - Longitude : -0.128005\"},\r\n\t\t{\"lat\":38.706932, \"lng\":-9.1356321, \"html\":\"Lisbonne - Latitude : 38.706932 - Longitude : -9.1356321\"},\r\n\t\t{\"lat\":52.2296756, \"lng\":21.0122287, \"html\":\"Varsovie - Latitude : 52.2296756 - Longitude : 21.0122287\"},\r\n\t\t{\"lat\":50.0878114, \"lng\":14.4204598, \"html\":\"Prague - Latitude : 50.0878114 - Longitude : 14.4204598\"},\r\n\t\t{\"lat\":47.4984056, \"lng\":19.0407578, \"html\":\"Budapest - Latitude : 47.4984056 - Longitude : 19.0407578\"},\r\n\t\t{\"lat\":55.6760968, \"lng\":12.5683371, \"html\":\"Copenhague - Latitude : 55.6760968 - Longitude : 12.5683371\"}\r\n\r\n\t   ]\r\n\t}\r\n<\/pre>\n<p><b>Le fichier HTML qui va nous permettre de charger l&#8217;ensemble <code>le_jeu_des_capitales.html<\/code><\/b><\/p>\n<pre lang=\"html\" escaped=\"true\">\r\n\t\r\n\t&lt;!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\r\n\t  \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\"&gt;\r\n\t&lt;html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"&gt;\r\n\t  &lt;head&gt;\r\n\t    &lt;meta http-equiv=\"content-type\" content=\"text\/html; charset=utf-8\"\/&gt;\r\n\t    &lt;title&gt;le_jeu_des_capitales&lt;\/title&gt;\r\n\t    &lt;script src=\"http:\/\/maps.google.com\/maps?file=api\" type=\"text\/javascript\"&gt;&lt;\/script&gt;\r\n\r\n\r\n\t&lt;script type=\"text\/javascript\"&gt;\r\n\r\n\r\n\t    \/\/&lt;![CDATA[\r\n\t    var map;\r\n\r\n\tfunction createMarker(point,html) {\r\n\t\tvar marker = new GMarker(point);\r\n\t      GEvent.addListener(marker, \"click\", function() {\r\n\t        marker.openInfoWindowHtml(html);\r\n\t      });\r\n\t      return marker;\r\n\t    }\r\n\r\n\t    setup_json = function(json, status) {\r\n\t      var data = eval(&#x27;(&#x27; + json + &#x27;)&#x27;);\r\n\r\n\t      for (var i=0; i&lt;data.markers.length; i++) {\r\n\t        var point = new GLatLng(data.markers[i].lat, data.markers[i].lng);\r\n\t        var marker = createMarker(point, data.markers[i].html);\r\n\t        map.addOverlay(marker);\r\n\t      }\r\n\t    }\r\n\r\n\t    function load() {\r\n\t      if (GBrowserIsCompatible()) {\r\n\t        map = new GMap2(document.getElementById(\"map\"));\r\n\t        map.addControl(new GLargeMapControl());\r\n\t        map.addControl(new GMapTypeControl());\r\n\t        map.setCenter(new GLatLng(46.85, 1.75), 4);\r\n\r\n\t        GDownloadUrl(\"le_jeu_des_capitales.json\", setup_json);\r\n\t      } else {\r\n\t        alert(\"D&eacute;sol&eacute;, l&#x27;API Google Maps n&#x27;est pas compatible avec votre navigateur.\");\r\n\t      }\r\n\t    }\r\n\r\n\t    \/\/]]&gt;\r\n\t    &lt;\/script&gt;\r\n\t  &lt;\/head&gt;\r\n\r\n\t  &lt;body onload=\"load()\" onunload=\"GUnload()\"&gt;\r\n\r\n\t\t\t\t&lt;div id=\"map\" style=\"width: 650px; height: 650px\"&gt;&lt;\/div&gt;\r\n\r\n\t  &lt;\/body&gt;\r\n\t&lt;\/html&gt;\r\n<\/pre>\n<p><i>Source : <a href=\"http:\/\/www.numabilis.com\/\" target=\"_blank\">http:\/\/www.numabilis.com\/<\/a><\/i><\/p>\n<p><b>Le rendu du fichier HTML <code>le_jeu_des_capitales.html<\/code><\/b><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/flaven.fr\/wp-content\/uploads\/2012\/06\/google_map_usage_1.jpg\" alt=\"Google Maps, JavaScript, API - Notions de base de la Google Maps JavaScript API et une approche sur le datajournalisme\" width=\"500\" height=\"265\" \/><\/p>\n<h2>En savoir plus<\/h2>\n<ul>\n<li>Events &#8211; Google Maps JavaScript API v3<br \/><a href=\"http:\/\/code.google.com\/intl\/fr\/apis\/maps\/documentation\/javascript\/events.html\" target=\"_blank\">http:\/\/code.google.com\/intl\/fr\/apis\/maps\/documentation\/javascript\/events.html<\/a><\/li>\n<li>Google Maps JavaScript API v3 Example: Event Closure<br \/><a href=\"http:\/\/code.google.com\/intl\/fr\/apis\/maps\/documentation\/javascript\/examples\/event-closure.html\" target=\"_blank\">http:\/\/code.google.com\/intl\/fr\/apis\/maps\/documentation\/javascript\/examples\/event-closure.html<\/a><\/li>\n<li>Google Maps JavaScript API v3 Example: Complex Icons<br \/><a href=\"https:\/\/google-developers.appspot.com\/maps\/documentation\/javascript\/examples\/icon-complex?hl=fr\" target=\"_blank\">https:\/\/google-developers.appspot.com\/maps\/documentation\/javascript\/examples\/icon-complex?hl=fr<\/a><\/li>\n<li>Random Markers<br \/><a href=\"http:\/\/gmaps-samples-v3.googlecode.com\/svn\/trunk\/sidebar\/random-markers.html\" target=\"_blank\">http:\/\/gmaps-samples-v3.googlecode.com\/svn\/trunk\/sidebar\/random-markers.html<\/a><\/li>\n<li>Google Maps JavaScript API v3 Example: Info Window Custom<br \/><a href=\"http:\/\/gmaps-samples-v3.googlecode.com\/svn\/trunk\/infowindow_custom\/infowindow-custom.html\" target=\"_blank\">http:\/\/gmaps-samples-v3.googlecode.com\/svn\/trunk\/infowindow_custom\/infowindow-custom.html<\/a><\/li>\n<li>Google Maps API : affichage des donn\u00e9es d&#8217;un fichier JSON<br \/><a href=\"http:\/\/www.numabilis.com\/index.php?post\/2007-07-07-google_maps_api_affichage_des_donnees_dun_fichier_json\" target=\"_blank\">http:\/\/www.numabilis.com\/index.php?post\/2007-07-07-google_maps_api_affichage_des_donnees_dun_fichier_json<\/a><\/li>\n<li>google-maps-utility-library-v3<br \/><a href=\"http:\/\/google-maps-utility-library-v3.googlecode.com\/svn\/trunk\/markerclusterer\/examples\/speed_test_example.html\" target=\"_blank\">http:\/\/google-maps-utility-library-v3.googlecode.com\/svn\/trunk\/markerclusterer\/examples\/speed_test_example.html<\/a><\/li>\n<li>google-maps-utility-library-v3<br \/><a href=\"http:\/\/www.mosne.it\/playground\/mosne_map\/\" target=\"_blank\">http:\/\/www.mosne.it\/playground\/mosne_map\/<\/a><\/li>\n<li>MarkerClusterer: A Solution to the Too Many Markers Problem<br \/><a href=\"http:\/\/googlegeodevelopers.blogspot.fr\/2009\/04\/markerclusterer-solution-to-too-many.html\" target=\"_blank\">http:\/\/googlegeodevelopers.blogspot.fr\/2009\/04\/markerclusterer-solution-to-too-many.html<\/a><\/li>\n<li>R\u00e9cup\u00e9rer les coordonn\u00e9es d\u2019une adresse avec google map<br \/><a href=\"http:\/\/www.weboblog.fr\/recuperer-les-coordonnees-dune-adresse\" target=\"_blank\">http:\/\/www.weboblog.fr\/recuperer-les-coordonnees-dune-adresse<\/a><\/li>\n<li>The Data Journalism Handbook &#8211; Some Favorite Examples<br \/><a href=\"http:\/\/datajournalismhandbook.org\/1.0\/en\/introduction_3.html\" target=\"_blank\">http:\/\/datajournalismhandbook.org\/1.0\/en\/introduction_3.html<\/a><\/li>\n<li>Five great examples of data journalism using Google Fusion Tables<br \/><a href=\"http:\/\/blogs.journalism.co.uk\/2011\/05\/20\/five-great-examples-of-data-journalism-using-google-fusion-tables\/\" target=\"_blank\">http:\/\/blogs.journalism.co.uk\/2011\/05\/20\/five-great-examples-of-data-journalism-using-google-fusion-tables\/<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Il existe de tr\u00e8s nombreux usages possibles de l&#8217;API Google Maps afin de faire des cartes personnalis\u00e9s notamment. Le plus \u00e9tourdissant dans cette personnalisation est,&hellip; <\/p>\n<p class=\"text-center\"><a href=\"https:\/\/flaven.fr\/2012\/06\/google-maps-javascript-api-notions-de-base-de-la-google-maps-javascript-api-et-une-approche-sur-le-datajournalisme\/\" class=\"more-link\">Continue reading &rarr; <span class=\"screen-reader-text\">Google Maps, JavaScript, API &#8211; Notions de base de la Google Maps JavaScript API et une approche sur le datajournalisme<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":9395,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"bf_ai_meta_description":"La Google Maps JavaScript API permet de cr\u00e9er des cartes personnalis\u00e9es. Lier les donn\u00e9es \u00e0 des marqueurs dynamiques enrichit le datajournalisme. Exemples: WikiLeaks, Texas Tribune.","bf_ai_og_title":"Google Maps API et datajournalisme","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[3444,3445,3447,3449,3451],"tags":[2183,446,447,448,449,450,451,452,453,278,454,226,455,456,457,458,459],"class_list":["post-2197","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programming-databases","category-seo-web-marketing","category-technology-trends","category-tutorials-how-to","category-web-design-front-end","tag-api","tag-data-journalism","tag-data-visualisation","tag-datajournalism","tag-datajournalisme","tag-evenement","tag-fermeture","tag-geolocalisation","tag-google-fusion-tables","tag-google-maps","tag-icones","tag-javascript","tag-online-map","tag-ouverture","tag-texas-tribune","tag-the-guardian","tag-the-telegraph"],"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p3Vuhl-zr","jetpack_featured_media_url":"https:\/\/flaven.fr\/wp-content\/uploads\/2012\/06\/google_map_usage_b_n_g_bf.jpg","_links":{"self":[{"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/posts\/2197","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/comments?post=2197"}],"version-history":[{"count":1,"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/posts\/2197\/revisions"}],"predecessor-version":[{"id":9396,"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/posts\/2197\/revisions\/9396"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/media\/9395"}],"wp:attachment":[{"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/media?parent=2197"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/categories?post=2197"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/tags?post=2197"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}