function showPointDetails()
{
      // This function needs the overlay from showMapPointInfo()
      // but it's a callback function.
      // How to get the overlay in here at the time of the callback?
      // I want to attach an openInfoWindowHTML to it

      // Fetch goodies regarding the clicked overlay from the server
      // Open an info window with that information.
      // Remove openInfoWindowHTML from showMapPointInfo
};

function showMapPointInfo(overlay, point)
{
     if (overlay)
     {
         log (overlay.id);
         overlay.openInfoWindowHtml(overlay.id);
         //var url = '/map/' + escape(overlay.id) + '/map_point_detail/';
         //var myPoints = loadJSONDoc(url);
         //myPoints.addCallbacks(showPointDetails,pointsFetchFailed);
     }
     else if (point)
     {
         map.addOverlay(new GMarker(point));
     }
};

function updateMapPoints()
{
     var mapBounds = map.getBounds();
     var url = '/map/' + escape(mapBounds) + '/map_points_in_bounds/';
     var myPoints = loadJSONDoc(url);
     myPoints.addCallbacks(processPoints,pointsFetchFailed);
};

function processPoints (myPoints)
{
     map.clearOverlays();
     point_count = myPoints.length;
     for (var k = 0; k < point_count; k++ ) {
         var mapPoint = new GLatLng(myPoints[k].lat,myPoints[k].lng);
         var mapMarker = new GMarker(mapPoint);
         mapMarker.id = myPoints[k].tag;
         map.addOverlay(mapMarker);
     };
};

function pointsFetchFailed (err) {
     alert("Fetching points failed: " + err);
};

function initMap()
{
     map = new GMap2(document.getElementById("map"));
     map.addControl(new GLargeMapControl());
     map.addControl(new GMapTypeControl());
     map.addControl(new GScaleControl(), new 
GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(20,20)));
     map.setCenter(new GLatLng(44.937585003910904, -122.991943359375), 7);
     updateMapPoints();
     var clickListener = GEvent.addListener(map,"click",function(overlay, 
point) {
         showMapPointInfo(overlay, point);
         } );
     var dragendListener = GEvent.addListener(map,"dragend",function() {
         updateMapPoints();
         } );
     var maptypechangedListener = 
GEvent.addListener(map,"maptypechanged",function() {
         updateMapPoints();
         } );
     var zoomendListener = 
GEvent.addListener(map,"zoomend",function(previousZoomLevel, currentZoomLevel) {
         updateMapPoints();
         } );
};

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~----------~----~----~----~------~----~------~--~---

Reply via email to