Changeset 33169

Show
Ignore:
Timestamp:
20.06.2019 18:40:03 (4 weeks ago)
Author:
wy59
Message:

Introducing ShapesUtil?.numberOfCoordinatesInBounds() that is used to work out when there's multiple coords and when there's only one (single marker) for a document. In the latter case, it should zoom into the map the single marker in the centre.

Location:
main/trunk/greenstone3/web/interfaces/default/js
Files:
2 modified

Legend:

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

    r33168 r33169  
    534534} 
    535535 
     536 
     537ShapesUtil.numberOfCoordinatesInBounds = function (shape) { 
     538    if (shape.type === google.maps.drawing.OverlayType.MARKER){ 
     539        return 1; 
     540    } else if (shape.type === google.maps.drawing.OverlayType.RECTANGLE) { 
     541        return 4; 
     542    } else if (shape.type === google.maps.drawing.OverlayType.CIRCLE) {      
     543        return 4; // circles have a rectangular/square bounding box, so 4 coordinates to a circle's bounding box 
     544    } else if (shape.type === google.maps.drawing.OverlayType.POLYLINE || shape.type === google.maps.drawing.OverlayType.POLYGON) { 
     545        var path = shape.getPath(); 
     546        return path.length; 
     547    } 
     548     
     549    console.log("Unrecognised shape, can't calculate the number of coordinates in its bounds"); 
     550    return -1; 
     551} 
     552 
    536553ShapesUtil.overlayBounds = function (overlays) { 
    537554     
  • main/trunk/greenstone3/web/interfaces/default/js/map-scripts.js

    r33168 r33169  
    347347                    doc.shapes[x].setVisible(false); 
    348348                } 
    349                 //markersOnMap += doc.shapes.length; 
    350349            } else { 
    351350                doc.marker.setVisible(false); 
     
    359358                for(var x = 0; x < doc.shapes.length; x++) {                     
    360359                    doc.shapes[x].setVisible(true); 
    361                 } 
    362                 markersOnMap += doc.shapes.length; 
    363                 //alert("HERE I AM " + markersOnMap); 
    364                  
     360                    markersOnMap += ShapesUtil.numberOfCoordinatesInBounds(doc.shapes[x]); 
     361                }                
    365362            } else { 
    366363                doc.marker.setVisible(true); 
     
    381378        if(doc.mapoverlay) { 
    382379            console.log("@@@@ HERE IN doc.mapoverlay"); 
    383             var overlay_bounds = ShapesUtil.overlayBounds(doc.shapes); 
    384             bounds.extend(overlay_bounds.getNorthEast()); 
    385             bounds.extend(overlay_bounds.getSouthWest()); 
     380            bounds = ShapesUtil.overlayBounds(doc.shapes); 
    386381        } 
    387382        else {