geojs 1.13.1 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/geo.js +55 -17
- package/geo.lean.js +55 -17
- package/geo.lean.min.js +1 -1
- package/geo.min.js +1 -1
- package/package.json +1 -1
- package/src/map.js +50 -12
package/package.json
CHANGED
package/src/map.js
CHANGED
|
@@ -409,11 +409,13 @@ var map = function (arg) {
|
|
|
409
409
|
* option when determining the new view.
|
|
410
410
|
* @param {boolean} [ignoreClampBounds] If `true`, ignore the clampBounds
|
|
411
411
|
* 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.
|
|
412
414
|
* @returns {number|this}
|
|
413
415
|
* @fires geo.event.zoom
|
|
414
416
|
* @fires geo.event.pan
|
|
415
417
|
*/
|
|
416
|
-
this.zoom = function (val, origin, ignoreDiscreteZoom, ignoreClampBounds) {
|
|
418
|
+
this.zoom = function (val, origin, ignoreDiscreteZoom, ignoreClampBounds, noTrigger) {
|
|
417
419
|
if (val === undefined) {
|
|
418
420
|
return m_zoom;
|
|
419
421
|
}
|
|
@@ -442,19 +444,49 @@ var map = function (arg) {
|
|
|
442
444
|
zoomLevel: m_zoom,
|
|
443
445
|
screenPosition: origin ? origin.map : undefined
|
|
444
446
|
};
|
|
445
|
-
|
|
447
|
+
if (!noTrigger || noTrigger === 'pan') {
|
|
448
|
+
m_this.geoTrigger(geo_event.zoom, evt);
|
|
449
|
+
}
|
|
446
450
|
|
|
447
451
|
if (aroundPoint) {
|
|
448
452
|
var shifted = m_this.gcsToDisplay(origin.mapgcs || origin.geo,
|
|
449
453
|
origin.mapgcs ? null : undefined);
|
|
450
454
|
m_this.pan({x: origin.map.x - shifted.x, y: origin.map.y - shifted.y},
|
|
451
|
-
ignoreDiscreteZoom, true);
|
|
455
|
+
ignoreDiscreteZoom, true, noTrigger);
|
|
452
456
|
} else {
|
|
453
|
-
m_this.pan({x: 0, y: 0}, ignoreDiscreteZoom, ignoreClampBounds);
|
|
457
|
+
m_this.pan({x: 0, y: 0}, ignoreDiscreteZoom, ignoreClampBounds, noTrigger);
|
|
454
458
|
}
|
|
455
459
|
return m_this;
|
|
456
460
|
};
|
|
457
461
|
|
|
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
|
+
|
|
458
490
|
/**
|
|
459
491
|
* Pan the map by a number of display pixels.
|
|
460
492
|
*
|
|
@@ -468,10 +500,11 @@ var map = function (arg) {
|
|
|
468
500
|
* view. When `'limited'`, the `clampBoundsX` and `clampBoundsY` options
|
|
469
501
|
* are selectively enforced so that the map will not end up more out of
|
|
470
502
|
* bounds than its current state.
|
|
503
|
+
* @param {boolean} [noTrigger] If truthy, do not trigger a pan event.
|
|
471
504
|
* @returns {this}
|
|
472
505
|
* @fires geo.event.pan
|
|
473
506
|
*/
|
|
474
|
-
this.pan = function (delta, ignoreDiscreteZoom, ignoreClampBounds) {
|
|
507
|
+
this.pan = function (delta, ignoreDiscreteZoom, ignoreClampBounds, noTrigger) {
|
|
475
508
|
var evt = {
|
|
476
509
|
screenDelta: delta
|
|
477
510
|
};
|
|
@@ -510,7 +543,9 @@ var map = function (arg) {
|
|
|
510
543
|
y: m_height / 2
|
|
511
544
|
});
|
|
512
545
|
|
|
513
|
-
|
|
546
|
+
if (!noTrigger) {
|
|
547
|
+
m_this.geoTrigger(geo_event.pan, evt);
|
|
548
|
+
}
|
|
514
549
|
|
|
515
550
|
m_this.modified();
|
|
516
551
|
return m_this;
|
|
@@ -575,7 +610,7 @@ var map = function (arg) {
|
|
|
575
610
|
/**
|
|
576
611
|
* Get or set the center of the map in the given geographic coordinates.
|
|
577
612
|
*
|
|
578
|
-
* @param {geo.geoPosition} coordinates If specified, the new center of the
|
|
613
|
+
* @param {geo.geoPosition} [coordinates] If specified, the new center of the
|
|
579
614
|
* map.
|
|
580
615
|
* @param {string|geo.transform|null} [gcs] `undefined` to use the interface
|
|
581
616
|
* gcs, `null` to use the map gcs, or any other transform. If setting the
|
|
@@ -588,10 +623,11 @@ var map = function (arg) {
|
|
|
588
623
|
* view. When `'limited'`, the `clampBoundsX` and `clampBoundsY` options
|
|
589
624
|
* are selectively enforced so that the map will not end up more out of
|
|
590
625
|
* bounds than its current state.
|
|
626
|
+
* @param {boolean} [noTrigger] If truthy, do not trigger a pan event.
|
|
591
627
|
* @returns {geo.geoPosition|this}
|
|
592
628
|
* @fires geo.event.pan
|
|
593
629
|
*/
|
|
594
|
-
this.center = function (coordinates, gcs, ignoreDiscreteZoom, ignoreClampBounds) {
|
|
630
|
+
this.center = function (coordinates, gcs, ignoreDiscreteZoom, ignoreClampBounds, noTrigger) {
|
|
595
631
|
var center;
|
|
596
632
|
if (coordinates === undefined) {
|
|
597
633
|
center = Object.assign({}, m_this.worldToGcs(m_center, gcs));
|
|
@@ -606,9 +642,11 @@ var map = function (arg) {
|
|
|
606
642
|
ignoreClampBounds), m_rotation);
|
|
607
643
|
m_this.modified();
|
|
608
644
|
// trigger a pan event
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
645
|
+
if (!noTrigger) {
|
|
646
|
+
m_this.geoTrigger(geo_event.pan, {
|
|
647
|
+
screenDelta: {x: 0, y: 0}
|
|
648
|
+
});
|
|
649
|
+
}
|
|
612
650
|
return m_this;
|
|
613
651
|
};
|
|
614
652
|
|
|
@@ -1383,7 +1421,7 @@ var map = function (arg) {
|
|
|
1383
1421
|
|
|
1384
1422
|
// This might have consequences in terms of bounds/zoom clamping.
|
|
1385
1423
|
// 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');
|
|
1387
1425
|
m_this.center(nav.center, null);
|
|
1388
1426
|
}
|
|
1389
1427
|
|