{"id":15782,"date":"2015-07-06T05:01:05","date_gmt":"2015-07-05T19:01:05","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=15782"},"modified":"2017-10-09T15:59:31","modified_gmt":"2017-10-09T05:59:31","slug":"phpjavascripthtml-google-chart-map-tooltips-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/phpjavascripthtml-google-chart-map-tooltips-tutorial\/","title":{"rendered":"PHP\/Javascript\/HTML Google Chart Map Tooltips Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Map\/map.php\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"PHP\/Javascript\/HTML Google Chart Map Tooltips Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Map\/map_tooltips.jpg\" title=\"PHP\/Javascript\/HTML Google Chart Map Tooltips Tutorial\"  \/><\/a><p class=\"wp-caption-text\">PHP\/Javascript\/HTML Google Chart Map Tooltips Tutorial<\/p><\/div>\n<p>Here is a tutorial that is revisiting Google Graphs API, or Google Chart Tools, and its Map functionality, which we first talked about with <a target=_blank title='PHP\/Javascript\/HTML Google Chart Map Tutorial' href='#pjhgmt'>PHP\/Javascript\/HTML Google Chart Map Tutorial<\/a> as shown below.  Please <a target=_blank title='Google Charts mission statement' href='https:\/\/developers.google.com\/chart\/interactive\/docs\/'>read<\/a> &#8230;<\/p>\n<blockquote><p>Google Chart Tools provide a perfect way to visualize data on your website. From simple line charts to complex hierarchical tree maps, the chart galley provides a large number of well-designed chart types. Populating your data is easy using the provided client- and server-side tools.<\/p><\/blockquote>\n<p>Why are we revisiting?  Well, we are interested in the interactive side to this wonderful product.  We are going to start with a look into <a target=_blank title='Tooltips information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Tooltip'>&#8220;tooltips&#8221;<\/a>.  Tooltips are those optional informational features of some webpages that happen when hovering over an HTML element, principally through the filling out of an HTML element&#8217;s <a target=_blank title='HTML global attribute of title information from w3schools' href='http:\/\/www.w3schools.com\/tags\/att_global_title.asp'>title<\/a> global attribute.  Google Charts functionality amounts to the use of Javascript, and, these days, <a target=_blank title='SVG information from w3schools' href='http:\/\/www.w3schools.com\/svg\/'>SVG<\/a> HTML elements, so &#8220;tooltips&#8221; are very relevant to the &#8220;user experience&#8221; when using Google Charts.  With the Map Chart, the latitude, longitude set is combined with a title, which can be the default &#8220;tooltip&#8221; shown, as this is all fine for many usages, but we want to extend it so that that title doesn&#8217;t have to be the tooltip.<\/p>\n<p>The integration of this added functionality into the Google Chart Map Chart involves adding an extra &#8220;string&#8221; column to the data table as per the <b>bold<\/b> bits of the new Javascript (via PHP) snippet &#8230;<\/p>\n<p><code><br \/>\n<b><br \/>\n if (isset($_GET['value']) && (isset($_GET['tooltip']) || strpos($GETdata, \"'\") !== false)) {<br \/>\n  echo \"   var data = new google.visualization.DataTable(); \/\" . \"\/\" . $GETlabel . $GETvalue . \" \\n\";<br \/>\n  echo \"   data.addColumn('number', '\" . str_replace(\"'\",\"\",str_replace(\",\",\"\",str_replace(\"['\",\"\",$GETlabel))) . \"');  \\n\";<br \/>\n  echo \"   data.addColumn('number', \" . str_replace(\",\", \"); data.addColumn({'type': 'string', 'role': 'tooltip', 'p': {'html': true}}); data.addColumn('string', \", str_replace(\"]\",\"\",$GETvalue)) . \");  \\n\";<br \/>\n  echo \"   data.addRows([ \\n\";<br \/>\n  echo str_replace(\"''\" . \"''\", \"''\", str_replace(\"~\", \"'\", substr($GETdata,1)));<br \/>\n  echo \"   ]); \\n\";<br \/>\n } else {<br \/>\n <\/b><br \/>\n      echo ' var data = google.visualization.arrayToDataTable([ ' . \"\\n\";<br \/>\n      echo \" \" . $GETlabel . $GETvalue . \" \\n\";<br \/>\n      echo str_replace(\"''\" . \"''\", \"''\", str_replace(\"~\", \"'\", $GETdata));<br \/>\n      echo \"        ]);\\n\";<br \/>\n<b> }<\/b><br \/>\n<\/code><\/p>\n<p> &#8230; making use of $_GET[] parameters coming into the PHP at the server side &#8230; you&#8217;ll find that Javascript loves to work with PHP as one of those <a target=_blank title='Fred and Ginger' href='http:\/\/www.youtube.com\/watch?v=MsS7B8nyw5Y'>Fred and Ginger<\/a> relationships of the programming world &#8230; you&#8217;ll be happier writing Javascript from your PHP too &#8230; try it and you&#8217;ll see the advantages time and again and again and again &#8230; did we leave out one? &#8230; <font size=0>and again<\/font>.<\/p>\n<p>The bigger picture plan for how this helps something else we are trying will hopefully become apparent over time.<\/p>\n<p>Let&#8217;s see some PHP code in <a target=_blank title='click picture' href='http:\/\/www.rjmprogramming.com.au\/PHP\/Map\/map.php'>live action<\/a> for this tutorial where you define your map characteristics and data.<\/p>\n<p>Link to Google Chart Tools &#8220;spiritual home&#8221; &#8230; <a target=_blank href='https:\/\/developers.google.com\/chart\/interactive\/docs\/index' title='Google Chart Tools provide a perfect way to visualize data on your website. From simple line charts to complex hierarchical tree maps, the chart galley provides a large number of well-designed chart types. Populating your data is easy using the provided client- and server-side tools.\n'>via Google<\/a>.<br \/>\nLink to Google Chart Tools Map information &#8230; <a target=_blank href='https:\/\/developers.google.com\/chart\/interactive\/docs\/gallery\/map' title='Google Map (chart)'>via Google<\/a>.<br \/>\nLink to Google Chart tooltips information &#8230; <a target=_blank href='https:\/\/developers.google.com\/chart\/interactive\/docs\/customizing_tooltip_content' title='Google Map (chart) tooltips information'>via Google<\/a>.<\/p>\n<p>Link to some downloadable PHP programming code &#8230; rename to <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/PHP\/Map\/map.php--GETME' title='Download me'>map.php<\/a> which changed from the days of <a target=_blank href='https:\/\/www.rjmprogramming.com.au\/ITblog\/google-charts-emailing-primer-tutorial\/' title='Google Charts Emailing Primer Tutorial'>Google Charts Emailing Primer Tutorial<\/a> as per <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/PHP\/Map\/map.php--GETME' title='map.php'>this link<\/a>.<\/p>\n<hr>\n<p id='pjhgmt'>Previous relevant <a target=_blank title='PHP\/Javascript\/HTML Google Chart Map Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/phpjavascripthtml-google-chart-map-tutorial'>PHP\/Javascript\/HTML Google Chart Map Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Map\/map.php\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"PHP\/Javascript\/HTML Google Chart Map Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Map\/GoogleChart_Map.jpg\" title=\"PHP\/Javascript\/HTML Google Chart Map Tutorial\"  \/><\/a><p class=\"wp-caption-text\">PHP\/Javascript\/HTML Google Chart Map Tutorial<\/p><\/div>\n<p>Here is a tutorial that introduces you to Google Graphs API, or Google Chart Tools, and its Map functionality.<\/p>\n<blockquote><p>Google Chart Tools provide a perfect way to visualize data on your website. From simple line charts to complex hierarchical tree maps, the chart galley provides a large number of well-designed chart types. Populating your data is easy using the provided client- and server-side tools.<\/p><\/blockquote>\n<p>Let&#8217;s see some  <a target=_blank title='click picture' href='http:\/\/www.rjmprogramming.com.au\/PHP\/Map\/map.php'>PHP<\/a> code in live action for this tutorial where you define your map characteristics and data.<\/p>\n<p>Link to Google Chart Tools &#8220;spiritual home&#8221; &#8230; <a target=_blank href='https:\/\/developers.google.com\/chart\/interactive\/docs\/index' title='Google Chart Tools provide a perfect way to visualize data on your website. From simple line charts to complex hierarchical tree maps, the chart galley provides a large number of well-designed chart types. Populating your data is easy using the provided client- and server-side tools.\n'>via Google<\/a>.<br \/>\nLink to Google Chart Tools Map information &#8230; <a target=_blank href='https:\/\/developers.google.com\/chart\/interactive\/docs\/gallery\/map' title='Google Map (chart)'>via Google<\/a>.<\/p>\n<p>Link to some downloadable PHP programming code &#8230; rename to <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/PHP\/Map\/map.php_GETME' title='Download me'>map.php<\/a>.\n<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d4832' onclick='var dv=document.getElementById(\"d4832\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?s=Google+Chart#content\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d4832' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d15782' onclick='var dv=document.getElementById(\"d15782\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/?tag=svg\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d15782' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Here is a tutorial that is revisiting Google Graphs API, or Google Chart Tools, and its Map functionality, which we first talked about with PHP\/Javascript\/HTML Google Chart Map Tutorial as shown below. Please read &#8230; Google Chart Tools provide a &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/phpjavascripthtml-google-chart-map-tooltips-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,14,37],"tags":[513,518,1608,576,652,745,871,932,997,1226,1609,1319],"class_list":["post-15782","post","type-post","status-publish","format-standard","hentry","category-elearning","category-event-driven-programming","category-tutorials","tag-google","tag-google-chart","tag-hover","tag-html","tag-javascript","tag-map","tag-onmouseover","tag-php","tag-programming","tag-svg","tag-tooltips","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/15782"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=15782"}],"version-history":[{"count":14,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/15782\/revisions"}],"predecessor-version":[{"id":33596,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/15782\/revisions\/33596"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=15782"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=15782"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=15782"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}