Changeset 33172


Ignore:
Timestamp:
2019-06-20T22:47:33+12:00 (5 years ago)
Author:
wy59
Message:

Second part of commit. Previous part detected whether we were in the import or buildcol phase and now, instead of during import, it would now during buildcol write out Coordinate meta extracted from GPS.mapoverlay meta. The previous commit worked without duplicating Coordinate meta in the index and didn't require the hack of testing whether the doc at a sectionID already had Coordinate meta calculated for it. The current commit 1. phases out the doc.coords variable, both when this array is created in the transform\xsl files and when it's used in map-scripts.js. 2. focusDocument now works with doc.shapes, panning to the overall doc.shapes' bounds and then opening any infomarkers (labels) for the selected doc's shapes.

Location:
main/trunk/greenstone3/web/interfaces/default
Files:
3 edited

Legend:

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

    r33169 r33172  
    367367        }
    368368       
    369         if(doc.coords) {
     369        /*if(doc.coords) {
    370370            //console.log("@@@@ HERE IN doc.coords");
    371371            for(var x = 0; x < doc.coords.length; x++) {
     
    374374                bounds.extend(new google.maps.LatLng(coordInfo.lat, coordInfo.lng));
    375375            }
    376         }
     376        }*/
    377377       
    378378        if(doc.mapoverlay) {
     
    495495
    496496function focusDocument(id)
    497 {
     497{   
    498498    var doc = _docList[id];
    499499    if(doc)
     
    501501        clearInterval(_intervalHandle);
    502502        _intervalHandle = null;
    503         if(doc.coords) {
     503         /*if(doc.coords) {
    504504            for(var x = 0; x < doc.coords.length; x++) {
    505505                var coord = doc.coords[x];
     
    507507                _map.panTo(new google.maps.LatLng(coordInfo.lat, coordInfo.lng));
    508508            }
     509        }*/
     510        if(doc.shapes) {           
     511            var docShapesBounds = ShapesUtil.overlayBounds(doc.shapes);
     512            _map.panToBounds(docShapesBounds); // https://developers.google.com/maps/documentation/javascript/reference/map#Map.panToBounds
    509513        } else {
    510514            _map.panTo(new google.maps.LatLng(doc.lat, doc.lng));
    511515        }
     516       
    512517        clearAllInfoBoxes();
    513         doc.marker.markerInfo.open(_map, doc.marker);
     518        if(doc.shapes) { // TODO       
     519            //console.log("Opening infowindow for doc " + doc.nodeID);
     520            for(var x = 0; x < doc.shapes.length; x++) {
     521                if(doc.shapes[x].markerInfo) {                 
     522                    doc.shapes[x].markerInfo.open(_map); // label
     523                }
     524                else {
     525                    console.log("No infowindow for doc " + doc.nodeID + "'s shape " + doc.shapes[x].type);
     526                }
     527            }
     528            //openInfoBoxes(doc);
     529        } else { // only Lat and Lng meta, so we have just one marker per doc, which will have the doc title not label
     530            doc.marker.markerInfo.open(_map, doc.marker); // doc title
     531        }
    514532        var scrollCheckbox = $("#scrollCheckbox");
    515533        if(scrollCheckbox.checked)
     
    525543    {
    526544        var doc = _docList.getDocByIndex(i);
    527         doc.marker.markerInfo.close();
     545       
     546        if(doc.shapes) {
     547            for(var x = 0; x < doc.shapes.length; x++) {
     548                if(doc.shapes[x].markerInfo) {
     549                    //console.log("Closing infowindow for doc " + _docList.ids[i]);
     550                    doc.shapes[x].markerInfo.close();                   
     551                }
     552            }
     553        }
     554        else { // only Lat and Lng meta, so we have just one marker per doc
     555            doc.marker.markerInfo.close();
     556        }
    528557    }
    529558}
     
    556585   
    557586    if(shape.type === google.maps.drawing.OverlayType.MARKER) {
    558         var marker = shape;     
     587        var marker = shape;
     588        console.log("Coord for marker is " + coord.toString());
     589       
    559590        marker.addListener('mouseover', function() {
    560591          infoWindow.open(_map, marker);
     
    578609    }
    579610    shape.markerInfo = infoWindow;
     611    console.log("######## Added markerInfo object to shape");   
    580612}
    581613
     
    623655        shape.draggable = false;
    624656       
    625        
     657        console.log("#### calling addInfoMarker");
    626658        // doc[i]'s label = doc.shapes[i].description
    627659        addInfoMarker(doc, shape);
    628     }   
     660    }
    629661   
    630662    var docElement = gs.jqGet("div" + doc.nodeID);
  • main/trunk/greenstone3/web/interfaces/default/transform/map-tools.xsl

    r33140 r33172  
    1818 
    1919  <xsl:template name="mapFeaturesJSONNodes">
    20     <div id="jsonNodes" style="display:none;">
     20    <div id="jsonNodes" style="display:none;" debug="true">
    2121      <xsl:text>[</xsl:text>
    2222      <xsl:for-each select="//documentNode">
     
    3737          <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Longitude']"/>
    3838      </xsl:if>
     39      <!--
    3940      <xsl:if test="metadataList/metadata[@name = 'Coordinate']">
    4041        <xsl:text disable-output-escaping="yes">,</xsl:text>
     
    4950        <xsl:text>]</xsl:text>
    5051      </xsl:if>
    51      
     52      -->
    5253      <xsl:if test="metadataList/metadata[@name = 'GPS.mapOverlay']">
    5354        <xsl:text disable-output-escaping="yes">,</xsl:text>
  • main/trunk/greenstone3/web/interfaces/default/transform/pages/document.xsl

    r33140 r33172  
    854854                                <xsl:text disable-output-escaping="yes">"lng":</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Longitude']"/>
    855855                            </xsl:if>
     856                            <!--
    856857                            <xsl:if test="metadataList/metadata[@name = 'Coordinate']">
    857858                                <xsl:text disable-output-escaping="yes">,</xsl:text>
     
    861862                                    <xsl:text disable-output-escaping="yes">"</xsl:text>
    862863                                    <xsl:value-of disable-output-escaping="yes" select="current()"/>
    863                                     <xsl:text disable-output-escaping="yes">"</xsl:text>
    864                                     <!--<xsl:if test="not(position() = count(metadataList/metadata[@name = 'Coordinate'])">
    865                                         <xsl:text>,</xsl:text>
    866                                     </xsl:if>               
    867                                     -->
     864                                    <xsl:text disable-output-escaping="yes">"</xsl:text>                           
    868865                                    <xsl:text disable-output-escaping="yes">,</xsl:text>
    869866                                </xsl:for-each>
    870867                                <xsl:text>]</xsl:text>
    871868                            </xsl:if>                       
    872                            
     869                            -->
    873870                            <xsl:if test="metadataList/metadata[@name = 'GPS.mapOverlay']">
    874871                                <xsl:text disable-output-escaping="yes">,</xsl:text>
     
    899896                                <xsl:text disable-output-escaping="yes">"lng":</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Longitude']"/>
    900897                            </xsl:if>
     898                            <!--
    901899                            <xsl:if test="metadataList/metadata[@name = 'Coordinate']">
    902900                                <xsl:text disable-output-escaping="yes">,</xsl:text>
     
    911909                                <xsl:text>]</xsl:text>
    912910                            </xsl:if>
    913                            
     911                            -->
    914912                            <xsl:if test="metadataList/metadata[@name = 'GPS.mapOverlay']">
    915913                                <xsl:text disable-output-escaping="yes">,</xsl:text>
Note: See TracChangeset for help on using the changeset viewer.