Ignore:
Timestamp:
2019-06-07T20:30:54+12:00 (5 years ago)
Author:
wy59
Message:
  1. Moved from plotting markers for each coord in doc.coords array to creating doc.mapOverlay from GPS.mapOverlay meta and converting each shape therein into Google Map Shapes/Overlays and storing these in the new doc.shapes array. 2. We now use Google Map InfoWindows to display label information for shapes/markers that have them. For now the labels are displayed/hidden on mouseover and mouseout. We can make them permanently displayed if necessary. 3. Lots more TODO questions added.
File:
1 edited

Legend:

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

    r33085 r33140  
    219219    var NE = new google.maps.LatLng(north, east);
    220220    var SW = new google.maps.LatLng(south, west);
    221     bounds = new google.maps.LatLngBounds(SW, NE);
     221    bounds = new google.maps.LatLngBounds(SW, NE); // THIS IS NOT IN GOOGLE MAPS' RECTANGLE FORMAT!
    222222   
    223223    var rect = ShapesUtil._createRectangle(json_rect,bounds);
     
    485485
    486486
     487// function returns an object (representing a Coordinate) of the form {lat: 34.052, lng: -118.243}
     488// For each shape's properties: https://developers.google.com/maps/documentation/javascript/shapes
     489ShapesUtil.getLabelCoordinate = function(shape) {   
     490   
     491    if (shape.type === google.maps.drawing.OverlayType.POLYLINE) {
     492        var path = shape.getPath(); // assuming a minimum of one path array for each polygon
     493        return path.getAt(0); // return the first coord of polyline for now
     494    } else if (shape.type === google.maps.drawing.OverlayType.POLYGON) {
     495        var path = shape.getPath(); // assuming a minimum of one path array for each polygon
     496        return path.getAt(0); // return the first coord for now
     497    } else if (shape.type === google.maps.drawing.OverlayType.RECTANGLE) {     
     498        // Doesn't work:
     499        //var latitude = (shape.bounds.north + shape.bounds.south) / 2;
     500        //var longitude = (shape.bounds.east + shape.bounds.west) / 2;
     501        //console.log("Rect: " + shape.bounds.toString());
     502        //return {lat: shape.bounds.north, lng: shape.bounds.east};
     503        // A Google Maps Rectangle's bounds property has 4 attributes/properties: north, south, east, west
     504        // But this ShapesUtil.Rectangle class's bounds property has 2 coord properties: SW and NE.
     505        // However, it is handy in this case, since we can just call getCenter()
     506        return shape.bounds.getCenter();
     507    } else if (shape.type === google.maps.drawing.OverlayType.CIRCLE) {     
     508        return shape.center; // circles have a centre
     509    } else if (shape.type === google.maps.drawing.OverlayType.MARKER){
     510        return shape.position;
     511    }
     512    else {
     513        console.error("*** ShapesUtil::getLabelCoordinate() Unrecognized shape type: " +shape.type);
     514        return null;
     515    }
     516}
     517
     518
Note: See TracChangeset for help on using the changeset viewer.