Question

I'm looking to make a fusion layer that allows user to select at least two markers at the same time in order to display a direct comparison of that data using charts.

I've been searching the Google Maps API and sample code section but I can't find any examples of when this has been implemeneted thus I'm at a bit of a loose end trying to do it.

Has anyone ever come across something like this or know if it's possible?

Was it helpful?

Solution

It's possible, when you click on a feature you'll receive the data for the feature, you only need to collect the data returned multiple clicks(e.g. in an array ) and build the query based on these data.

For the linked example the important row is the "County"-row, it will be used to filter the results. To get results for multiple counties us a IN()-condition.

the modified drawVisualization-function may look like this:

  //counties may either be 
  //a string(a single county)
  //or an array(1 or more counties)
function drawVisualization(counties) {
  counties=(typeof counties==='string')?[counties]:counties;
  google.visualization.drawChart({
    "containerId": "visualization",
    "dataSourceUrl": "http://www.google.com/fusiontables/gvizdata?tq=",
    "query": "SELECT County,'2010' FROM 1761814 WHERE County IN('"+counties.join("','")+"') and Sector='Total'",
    "chartType": "ColumnChart",
    "options": {
      "title": 'comparision',
      "height": 400,
      "width": 400
    }
  });
}

To be able to choose between single/multi-selection there may be many ways. You may e.g. use the CTRL-key to enable the multi-selection. Set a flag when the key is pressed, when the flag is set push the new County to the array, when not create a new array with the given County

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top