Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I've created this map -- https://s3.amazonaws.com/pdb.files/lookup_auto2.html -- using Google Fusion Tables and Google Maps API. I'm attempting to modify the code so that the map will pan and zoom after executing the query. It seems that I need to use either the fitBounds function to display the bounds of the results, or something simpler like this:

// Change the center and zoom of the map
      map.setCenter(results[0].geometry.location);
      map.setZoom(10);

I'd prefer the second option so that I can set a consistent zoom level for each query. Any pointers or references for completing this are much appreciated.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Add a spatial search to your code:

FUSION TABLES allows ST_INTERSECT to be performed full reference: http://code.google.com/apis/fusiontables/docs/developers_reference.html#Select (see <spatial_condition> )

      // OPTIONAL: find the new map bounds, and run a spatial query to return
  // Fusion Tables results within those bounds. 
  sw = map.getBounds().getSouthWest();
  ne = map.getBounds().getNorthEast();
  layer.setOptions({
    query: {
      select: 'lat',
      from: tableid,
      where: "ST_INTERSECTS(lat, RECTANGLE(LATLNG(" + sw.lat() + "," + sw.lng() + "), LATLNG(" + ne.lat() + "," + ne.lng() + ")))"
    }
  });

Full code: http://gmaps-samples.googlecode.com/svn/trunk/fusiontables/search_and_zoom.html (view source)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.