views:

19

answers:

1

I have a web app with a giant Google Map in it. As users pan and zoom around on the map, points are dynamically loaded through AJAX call which include the viewport bounds (NE and SW corner coordinates) and some other assorted parameters.

How do I cache these request for points? The problem is that the parameters are highly variable and (worst) not discrete i.e. floats with a lots of decimal places. I'm using ASP.NET-MVC/C#/LINQ2SQL/SQL-Server but the problem is not tied to that platform.

This is the signature of the the relevant method:

[AcceptVerbs(HttpVerbs.Post)]
public JsonResult Data(string date, string categories,
    string ne_lat, string ne_lng,
    string sw_lat, string sw_lng)
A: 

You maybe going about this the wrong way. Try loading your layer in as GGeoXML (or KML) rather than as a custom request for markers and then the Google API will handle which points to display and the caching.

    var myLatlng = new google.maps.LatLng(49.496675,-102.65625);
    var myOptions = {
      zoom: 4,
      center: myLatlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }

    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

    var georssLayer = new google.maps.KmlLayer('http://api.flickr.com/services/feeds/geo/?g=322338@N20〈=en-us&format=feed-georss');
georssLayer.setMap(map);

See http://code.google.com/apis/maps/documentation/v3/examples/layer-georss.html

If you need to refresh you points then add a (fake or timestamp) parameter to the end of the URL

http://myhost.com/file.kml?rand=1

geographika