@@ -491,7 +491,7 @@ var annotationLayer = function (arg) {
491491 * gcs, `null` to use the map gcs, or any other transform.
492492 * @param {boolean } [update] If `false`, don't update the layer after adding
493493 * the annotation.
494- * @param {boolean } [trigger] If `false`, do trigger add_before and add
494+ * @param {boolean } [trigger] If `false`, do not trigger add_before and add
495495 * events.
496496 * @returns {this } The current layer.
497497 * @fires geo.event.annotation.add_before
@@ -570,10 +570,11 @@ var annotationLayer = function (arg) {
570570 * the annotation.
571571 * @param {int } [pos] The posiiton of the annotation in the annotation list,
572572 * if known. This speeds up the process.
573+ * @param {boolean } [trigger] If `false`, do not trigger remove event.
573574 * @returns {boolean } `true` if an annotation was removed.
574575 * @fires geo.event.annotation.remove
575576 */
576- this . removeAnnotation = function ( annotation , update , pos ) {
577+ this . removeAnnotation = function ( annotation , update , pos , trigger ) {
577578 if ( annotation . id && m_annotationIds [ annotation . id ( ) ] !== undefined ) {
578579 pos = m_annotations . indexOf ( annotation ) ;
579580 if ( annotation === m_this . currentAnnotation ) {
@@ -588,9 +589,11 @@ var annotationLayer = function (arg) {
588589 m_this . modified ( ) ;
589590 m_this . draw ( ) ;
590591 }
591- m_this . geoTrigger ( geo_event . annotation . remove , {
592- annotation : annotation
593- } ) ;
592+ if ( trigger !== false ) {
593+ m_this . geoTrigger ( geo_event . annotation . remove , {
594+ annotation : annotation
595+ } ) ;
596+ }
594597 return true ;
595598 }
596599 return false ;
@@ -603,16 +606,17 @@ var annotationLayer = function (arg) {
603606 * are in the create state.
604607 * @param {boolean } [update] If `false`, don't update the layer after
605608 * removing the annotation.
609+ * @param {boolean } [trigger] If `false`, do not trigger remove events.
606610 * @returns {number } The number of annotations that were removed.
607611 */
608- this . removeAllAnnotations = function ( skipCreating , update ) {
612+ this . removeAllAnnotations = function ( skipCreating , update , trigger ) {
609613 var removed = 0 , annotation ;
610614 for ( let pos = m_annotations . length - 1 ; pos >= 0 ; pos -= 1 ) {
611615 annotation = m_annotations [ pos ] ;
612616 if ( skipCreating && annotation . state ( ) === geo_annotation . state . create ) {
613617 continue ;
614618 }
615- m_this . removeAnnotation ( annotation , false , pos ) ;
619+ m_this . removeAnnotation ( annotation , false , pos , trigger ) ;
616620 removed += 1 ;
617621 }
618622 if ( removed && update !== false ) {
0 commit comments