Tag Archive: google


Map of Canada chart with province value colour coding.

This is PHP class I developed for work when I needed a Canada-specific map chart in some reporting tools I was creating. Obviously Google’s Map Charts API would’ve been my first choice, but it didn’t support Canada as it’s zoom level for reporting province-based data sets.

This is where I sat down, thought about a quick and dirty way to create this chart and went to work. I was able to create a chart as show on the right, with full control of output dimensions and colours.

Before I jump right into the full code, I want give a brief explanation of some of the techniques I used to accomplish this task.

View full article »

So here’s a quick couple snippets of code that will allow you to retrieve the coordinates of two locations using Google Maps API — no API key necessary.

This first function will return the coordinates of specific address (I find pretty much anything works, whether it’s a full address with street number, or just a postal code, or simply a city name) as an array of coordinates:

function getCoordinates($address) {   $url = "http://maps.google.com/maps/geo?q=" . urlencode($address)          . "&output=json";   $result = file_get_contents($url);   $result = json_decode($result, 1);   if (isset($result['Placemark'])) {     list($lat, $long) = $result['Placemark'][0]['Point']['coordinates'];   } else {     $lat = $long = false;   }   return array($lat, $long); }

View full article »

Powered by WordPress | Theme: Motion by 85ideas.