@@ -409,11 +409,13 @@ var map = function (arg) {
409409 * option when determining the new view.
410410 * @param {boolean } [ignoreClampBounds] If `true`, ignore the clampBounds
411411 * option when determining the new view.
412+ * @param {boolean } [noTrigger] If truthy, do not trigger a pan or zoom
413+ * event. If 'pan', only trigger the zoom event.
412414 * @returns {number|this }
413415 * @fires geo.event.zoom
414416 * @fires geo.event.pan
415417 */
416- this . zoom = function ( val , origin , ignoreDiscreteZoom , ignoreClampBounds ) {
418+ this . zoom = function ( val , origin , ignoreDiscreteZoom , ignoreClampBounds , noTrigger ) {
417419 if ( val === undefined ) {
418420 return m_zoom ;
419421 }
@@ -442,19 +444,49 @@ var map = function (arg) {
442444 zoomLevel : m_zoom ,
443445 screenPosition : origin ? origin . map : undefined
444446 } ;
445- m_this . geoTrigger ( geo_event . zoom , evt ) ;
447+ if ( ! noTrigger || noTrigger === 'pan' ) {
448+ m_this . geoTrigger ( geo_event . zoom , evt ) ;
449+ }
446450
447451 if ( aroundPoint ) {
448452 var shifted = m_this . gcsToDisplay ( origin . mapgcs || origin . geo ,
449453 origin . mapgcs ? null : undefined ) ;
450454 m_this . pan ( { x : origin . map . x - shifted . x , y : origin . map . y - shifted . y } ,
451- ignoreDiscreteZoom , true ) ;
455+ ignoreDiscreteZoom , true , noTrigger ) ;
452456 } else {
453- m_this . pan ( { x : 0 , y : 0 } , ignoreDiscreteZoom , ignoreClampBounds ) ;
457+ m_this . pan ( { x : 0 , y : 0 } , ignoreDiscreteZoom , ignoreClampBounds , noTrigger ) ;
454458 }
455459 return m_this ;
456460 } ;
457461
462+ /**
463+ * Set zoom level and center of the map.
464+ *
465+ * @param {number } zoom The new zoom level to set.
466+ * @param {geo.geoPosition } center The new center of the
467+ * @param {string|geo.transform|null } [gcs] `undefined` to use the interface
468+ * gcs, `null` to use the map gcs, or any other transform. The center is
469+ * converted from this gcs to the map projection.
470+ * @param {geo.geoPosition } origin.geo The gcs coordinates of the zoom
471+ * center.
472+ * @param {geo.screenPosition } origin.map The display coordinates of the zoom
473+ * center.
474+ * @param {boolean } [ignoreDiscreteZoom] If `true`, ignore the discreteZoom
475+ * option when determining the new view.
476+ * @param {boolean } [ignoreClampBounds] If `true`, ignore the clampBounds
477+ * option when determining the new view.
478+ * @param {boolean } [noTrigger] If truthy, do not trigger a pan or zoom
479+ * event.
480+ * @returns {this }
481+ * @fires geo.event.zoom
482+ * @fires geo.event.pan
483+ */
484+ this . zoomAndCenter = function ( zoom , center , gcs , ignoreDiscreteZoom , ignoreClampBounds , noTrigger ) {
485+ this . zoom ( zoom , undefined , ignoreDiscreteZoom , ignoreClampBounds , noTrigger || 'pan' ) ;
486+ this . center ( center , gcs , ignoreDiscreteZoom , ignoreClampBounds , noTrigger ) ;
487+ return this ;
488+ } ;
489+
458490 /**
459491 * Pan the map by a number of display pixels.
460492 *
@@ -468,10 +500,11 @@ var map = function (arg) {
468500 * view. When `'limited'`, the `clampBoundsX` and `clampBoundsY` options
469501 * are selectively enforced so that the map will not end up more out of
470502 * bounds than its current state.
503+ * @param {boolean } [noTrigger] If truthy, do not trigger a pan event.
471504 * @returns {this }
472505 * @fires geo.event.pan
473506 */
474- this . pan = function ( delta , ignoreDiscreteZoom , ignoreClampBounds ) {
507+ this . pan = function ( delta , ignoreDiscreteZoom , ignoreClampBounds , noTrigger ) {
475508 var evt = {
476509 screenDelta : delta
477510 } ;
@@ -510,7 +543,9 @@ var map = function (arg) {
510543 y : m_height / 2
511544 } ) ;
512545
513- m_this . geoTrigger ( geo_event . pan , evt ) ;
546+ if ( ! noTrigger ) {
547+ m_this . geoTrigger ( geo_event . pan , evt ) ;
548+ }
514549
515550 m_this . modified ( ) ;
516551 return m_this ;
@@ -575,7 +610,7 @@ var map = function (arg) {
575610 /**
576611 * Get or set the center of the map in the given geographic coordinates.
577612 *
578- * @param {geo.geoPosition } coordinates If specified, the new center of the
613+ * @param {geo.geoPosition } [ coordinates] If specified, the new center of the
579614 * map.
580615 * @param {string|geo.transform|null } [gcs] `undefined` to use the interface
581616 * gcs, `null` to use the map gcs, or any other transform. If setting the
@@ -588,10 +623,11 @@ var map = function (arg) {
588623 * view. When `'limited'`, the `clampBoundsX` and `clampBoundsY` options
589624 * are selectively enforced so that the map will not end up more out of
590625 * bounds than its current state.
626+ * @param {boolean } [noTrigger] If truthy, do not trigger a pan event.
591627 * @returns {geo.geoPosition|this }
592628 * @fires geo.event.pan
593629 */
594- this . center = function ( coordinates , gcs , ignoreDiscreteZoom , ignoreClampBounds ) {
630+ this . center = function ( coordinates , gcs , ignoreDiscreteZoom , ignoreClampBounds , noTrigger ) {
595631 var center ;
596632 if ( coordinates === undefined ) {
597633 center = Object . assign ( { } , m_this . worldToGcs ( m_center , gcs ) ) ;
@@ -606,9 +642,11 @@ var map = function (arg) {
606642 ignoreClampBounds ) , m_rotation ) ;
607643 m_this . modified ( ) ;
608644 // trigger a pan event
609- m_this . geoTrigger ( geo_event . pan , {
610- screenDelta : { x : 0 , y : 0 }
611- } ) ;
645+ if ( ! noTrigger ) {
646+ m_this . geoTrigger ( geo_event . pan , {
647+ screenDelta : { x : 0 , y : 0 }
648+ } ) ;
649+ }
612650 return m_this ;
613651 } ;
614652
@@ -1383,7 +1421,7 @@ var map = function (arg) {
13831421
13841422 // This might have consequences in terms of bounds/zoom clamping.
13851423 // What behavior do we expect from this method in that case?
1386- m_this . zoom ( nav . zoom ) ;
1424+ m_this . zoom ( nav . zoom , undefined , undefined , undefined , 'pan' ) ;
13871425 m_this . center ( nav . center , null ) ;
13881426 }
13891427
0 commit comments