- Timestamp:
- 2019-06-20T17:13:50+12:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/web/interfaces/default/js/map-scripts-shapes-util.js
r33140 r33168 1 2 // https://stackoverflow.com/questions/3284808/getting-the-bounds-of-a-polyline-in-google-maps-api-v3 3 4 google.maps.Polyline.prototype.getBounds = function() { 5 var bounds = new google.maps.LatLngBounds(); 6 this.getPath().forEach(function(item, index) { 7 bounds.extend(new google.maps.LatLng(item.lat(), item.lng())); 8 }); 9 return bounds; 10 }; 11 12 google.maps.Polygon.prototype.getBounds = function() { 13 var bounds = new google.maps.LatLngBounds(); 14 this.getPath().forEach(function(item, index) { 15 bounds.extend(new google.maps.LatLng(item.lat(), item.lng())); 16 }); 17 return bounds; 18 }; 1 19 2 20 … … 516 534 } 517 535 518 536 ShapesUtil.overlayBounds = function (overlays) { 537 538 539 var extended_bounds = new google.maps.LatLngBounds(); 540 541 for (var i=0; i<overlays.length; i++) { 542 543 var overlay_item = overlays[i]; 544 545 if (ShapesUtil.overlayItemIsShape(overlay_item)) { 546 var shape = overlay_item; 547 548 var bounds = shape.getBounds(); 549 var ne = bounds.getNorthEast(); 550 var sw = bounds.getSouthWest(); 551 extended_bounds.extend(ne); 552 extended_bounds.extend(sw); 553 } 554 else { 555 var marker = overlay_item; 556 var latlng = marker.getPosition(); 557 extended_bounds.extend(latlng); 558 } 559 } 560 561 return extended_bounds; 562 563 } 564
Note:
See TracChangeset
for help on using the changeset viewer.