- Timestamp:
- 2019-06-07T20:30:54+12:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/web/interfaces/default/js/map-scripts-shapes-util.js
r33085 r33140 219 219 var NE = new google.maps.LatLng(north, east); 220 220 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! 222 222 223 223 var rect = ShapesUtil._createRectangle(json_rect,bounds); … … 485 485 486 486 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 489 ShapesUtil.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.