Trying to extend current GMaps extension to use Google Maps Heatmap Function.
Hello Guys,
I am building an App which will have a Heatmap plotted in a map. There are some options that can be used, but to start it I plan to use Google Maps API to do so. I have 2 options:
- Use Fusion Tables: it is simple to use but the data has to be stored into a Google Fusion Table in order to be used. The good thing is that the heatmap is Server Side Computed which can be an important point to performance.
- Use HeatMap Function: has more flexibility as the data can be passed dinamically but it is client side computed.
I decided to go for the 2nd option but I cannot get it to work because it requires the Visualization library to be included and I do not know where I should put it. Does anyone have an idea of how to declare it? Here is what I have to include:
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=visualization&sensor=true_or_false">
</script>
For the code, I included an option into the extension's googlemap.ide file to add an option in the UI to Enable the HeatMap;
'ShowHeatMap': {
'description': 'Show Fusion Tables HeatMap',
'isBindingTarget': true,
'defaultValue': false,
'baseType': 'BOOLEAN'
}
Also included in the googlemap.runtime file the API Call (almost copied and pasted from google):
if(this.getProperty('ShowHeatMap')){
/* Data points defined as an array of LatLng objects */
var heatmapData = [
new google.maps.LatLng(37.782, -122.447),
new google.maps.LatLng(37.782, -122.445),
new google.maps.LatLng(37.782, -122.443),
new google.maps.LatLng(37.782, -122.441),
new google.maps.LatLng(37.782, -122.439),
new google.maps.LatLng(37.782, -122.437),
new google.maps.LatLng(37.782, -122.435),
new google.maps.LatLng(37.785, -122.447),
new google.maps.LatLng(37.785, -122.445),
new google.maps.LatLng(37.785, -122.443),
new google.maps.LatLng(37.785, -122.441),
new google.maps.LatLng(37.785, -122.439),
new google.maps.LatLng(37.785, -122.437),
new google.maps.LatLng(37.785, -122.435)
];
var heatmap = new google.maps.visualization.HeatmapLayer({
data: heatmapData
});
heatmap.setMap(this.map);
}
Thanks a lot
Ewerton

