Ignore:
Timestamp:
2019-06-06T20:53:13+12:00 (5 years ago)
Author:
wy59
Message:

Improvements to Coordinate support AND bugfixes. BUT not all the fixes may be ideal, many marked with TODO. 1. Now we support an Array of coordinates. At present these are only displayed as Markers, but in future shapes should appear as shapes. 2. Bugfixes include: (a) expanding sections wasn't working when we had hierarchical docs with Coordinate data, because map-scripts 'overrode' the toggleSection function but no longer did any of the doc expanding behaviour that document_scripts.js used to do. This was not a problem with the ImagesGPS collection, simply because that did not have hierarchical/sectionalised documents. (b) Perl: A previous commit output duplicate Coordinates into the index. Now this doesn't happen. Fix works but may not be ideal. 3. Perl: (a) Reserved index names CD, CS for Coordinate and CoordShort. Note however that LAT and LNG were never added to reserve list for index names. (b) Now doc.pm::processCoord() takes a section parameter and works out the section-ptr from that.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/web/interfaces/default/js/map-scripts.js

    r33127 r33128  
    2424    if(jsonNodeDiv.length)
    2525    {
    26         console.log("@@@ JSON node div html: " + jsonNodeDiv.html());
     26        //console.log("@@@ JSON node div html: " + jsonNodeDiv.html());
    2727        var jsonNodes = eval(jsonNodeDiv.html());
    2828       
     
    3232            {
    3333                _docList[jsonNodes[i].nodeID] = jsonNodes[i];
    34                 _docList.ids.push(jsonNodes[i].nodeID);
    35                 console.log("@@@ JSON node: " + jsonNodes[i]);
    36                 createMarker(jsonNodes[i], true);
     34                _docList.ids.push(jsonNodes[i].nodeID);             
     35                createMarkers(jsonNodes[i], true);
    3736            }
    3837            updateMap();
     
    4039        else
    4140        {
     41            //hiding the map
    4242            //$("#map_canvas").css({visibility:"hidden", height:"0px"});
    43             $("#map_canvas").css({visibility:"hidden"});
    44             //console.log("suppressing hiding the map");
     43            $("#map_canvas").css({visibility:"hidden"}); // if you comment this out, add a log message saying "suppressing hiding map"
    4544        }
    4645    }
     
    9796   
    9897    if ($map_canvas.length > 0) {
    99         console.log("### map-scripts::setUpMap: map_canvas.exists");
    10098        _map = new google.maps.Map($map_canvas[0], myOptions);
    10199        google.maps.event.addListener(_map, 'bounds_changed', performSearchForMarkers);
     
    254252            var endIndex = responseText.indexOf("</");
    255253
    256             console.log("@@@@ performSearch, got response: " + responseText);
     254            //console.log("@@@@ performSearch, got response: " + responseText);
    257255
    258256            var jsonNodes = eval(responseText.substring(startIndex+1, endIndex));
     
    271269                        _docList.ids.push(doc.nodeID);
    272270
    273                         createMarker(doc, false);
     271                        createMarkers(doc, false);
    274272                    }
    275273                }
     
    337335        }
    338336
    339         if(doc.coord) {
    340             var coordInfo = getLatLngForCoord(doc.coord);
    341             bounds.extend(new google.maps.LatLng(coordInfo.lat, coordInfo.lng));
     337       
     338        if(doc.coords) {
     339            for(var x = 0; x < doc.coords.length; x++) {
     340                var coord = doc.coords[x];
     341                var coordInfo = getLatLngForCoord(doc.coords[x]);
     342                bounds.extend(new google.maps.LatLng(coordInfo.lat, coordInfo.lng));
     343            }
    342344        }
    343345        else {
     
    463465        clearInterval(_intervalHandle);
    464466        _intervalHandle = null;
    465         if(doc.coord) {
    466             var coordInfo = getLatLngForCoord(doc.coord);
    467             _map.panTo(new google.maps.LatLng(coordInfo.lat, coordInfo.lng));
     467        if(doc.coords) {
     468            for(var x = 0; x < doc.coords.length; x++) {
     469                var coord = doc.coords[x];
     470                var coordInfo = getLatLngForCoord(doc.coords[x]);
     471                _map.panTo(new google.maps.LatLng(coordInfo.lat, coordInfo.lng));
     472            }
    468473        } else {
    469474            _map.panTo(new google.maps.LatLng(doc.lat, doc.lng));
     
    488493}
    489494
    490 function createMarker(doc, mainMarker)
    491 {
    492     var pos;
    493     if(doc.coord) {
    494         var coordInfo = getLatLngForCoord(doc.coord);           
    495         pos = new google.maps.LatLng(coordInfo.lat,coordInfo.lng);     
     495function createMarkers(doc, mainMarker) {
     496    if(doc.coords) {
     497        for(var x = 0; x < doc.coords.length; x++) {
     498            var coord = doc.coords[x];
     499            var coordInfo = getLatLngForCoord(doc.coords[x]);
     500            pos = new google.maps.LatLng(coordInfo.lat,coordInfo.lng);         
     501            createMarker(doc, pos, mainMarker);
     502        }
    496503    } else {
    497504        pos = new google.maps.LatLng(doc.lat,doc.lng);
    498     }
    499    
    500    
     505        createMarker(doc, pos, mainMarker);
     506    }
     507}
     508
     509
     510// Param mainMarker: if set to true, marker is red. If false, marker is blue
     511function createMarker(doc, pos, mainMarker)
     512{
    501513    var docEdit = (("docEdit" in gs.cgiParams) && (gs.cgiParams['docEdit']));
    502514    //var draggable_val = (docEdit) ? true : false;
     
    609621                _docList.ids.push(doc.nodeID);
    610622
    611                 createMarker(doc, false);
     623                createMarkers(doc, false);
    612624            }
    613625           
     
    825837function modifyFunctions()
    826838{
    827     toggleSection = function(sectionID)
    828     {
     839    // This function "overrides" toggleSection in both classifier_scripts.js and document_scripts.js
     840    // However, classifier_scripts.js::toggleSection() only took one parameter, sectionID, whereas
     841    // document_scripts.js::toggleSection() took 3 params (sectionID, callback, tocDisabled).
     842    // So to be compatible with both, need map-scripts::toggleSection() here to support all 3 in that order.
     843    toggleSection = function(sectionID, callback, tocDisabled)
     844    {
     845        _basicToggleSection(sectionID, callback, tocDisabled);
     846       
    829847        var section = gs.jqGet("div" + sectionID);
    830         var sectionToggle = gs.jqGet("toggle" + sectionID);
    831        
     848        var sectionToggle = gs.jqGet("toggle" + sectionID);     
     849               
    832850        if(sectionToggle == undefined)
    833         {
     851        {           
    834852            return;
    835         }
     853        }       
    836854       
    837855        // Test if 'section' exists. 
     
    839857        // http://stackoverflow.com/questions/920236/how-can-i-detect-if-a-selector-returns-null
    840858        if(section.length !== 0)
    841         {           
     859        {              
    842860            if(isExpanded(sectionID))
    843861            {
     
    862880        {
    863881            httpRequest(sectionID);
    864         }
     882        }       
     883       
    865884    }
    866885   
     
    901920                    checkout();
    902921                }
     922                /*else if(gs.cgiParams.documentbasket == "on") // TODO: copied from classifier_scripts.js - should this else block be included here (and happen when mapEnabled) or not?
     923                {
     924                    dmcheckout();
     925                }*/
    903926                updateOpenClassifiers();
    904927                getSubClassifier(sectionID);
Note: See TracChangeset for help on using the changeset viewer.