@maptiler/client 1.0.3 → 1.1.1
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/dist/maptiler-client.cjs +586 -21
- package/dist/maptiler-client.cjs.map +1 -1
- package/dist/maptiler-client.d.ts +405 -2
- package/dist/maptiler-client.min.mjs +1 -1
- package/dist/maptiler-client.mjs +582 -22
- package/dist/maptiler-client.mjs.map +1 -1
- package/dist/maptiler-client.umd.js +586 -21
- package/dist/maptiler-client.umd.js.map +1 -1
- package/dist/maptiler-client.umd.min.js +1 -1
- package/docs/assets/custom.css +28 -1
- package/docs/classes/config.ClientConfig.html +9 -9
- package/docs/classes/services_ServiceError.ServiceError.html +7 -7
- package/docs/functions/language.getAutoLanguageGeocoding.html +5 -5
- package/docs/functions/services_simplify.default.html +5 -5
- package/docs/index.html +111 -30
- package/docs/modules/config.html +5 -5
- package/docs/modules/language.html +5 -5
- package/docs/modules/services_ServiceError.html +5 -5
- package/docs/modules/services_coordinates.html +5 -5
- package/docs/modules/services_data.html +5 -5
- package/docs/modules/services_geocoding.html +5 -5
- package/docs/modules/services_geolocation.html +5 -5
- package/docs/modules/services_simplify.html +5 -5
- package/docs/modules/services_staticMaps.html +5 -5
- package/docs/modules.html +4 -4
- package/docs/types/config.FetchFunction.html +5 -5
- package/docs/types/language.LanguageGeocodingString.html +5 -5
- package/docs/types/services_coordinates.CoordinateExport.html +5 -5
- package/docs/types/services_coordinates.CoordinateGrid.html +5 -5
- package/docs/types/services_coordinates.CoordinateId.html +5 -5
- package/docs/types/services_coordinates.CoordinateSearch.html +5 -5
- package/docs/types/services_coordinates.CoordinateSearchResult.html +5 -5
- package/docs/types/services_coordinates.CoordinateTransformResult.html +5 -5
- package/docs/types/services_coordinates.CoordinateTransformation.html +5 -5
- package/docs/types/services_coordinates.CoordinatesSearchOptions.html +5 -5
- package/docs/types/services_coordinates.CoordinatesTransformOptions.html +5 -5
- package/docs/types/services_coordinates.XYZ.html +5 -5
- package/docs/types/services_data.GetDataOptions.html +5 -5
- package/docs/types/services_geocoding.Coordinates.html +5 -5
- package/docs/types/services_geocoding.FeatureHierarchy.html +5 -5
- package/docs/types/services_geocoding.GeocodingFeature.html +5 -5
- package/docs/types/services_geocoding.GeocodingOptions.html +5 -5
- package/docs/types/services_geocoding.GeocodingSearchResult.html +5 -5
- package/docs/types/services_geocoding.ReverseGeocodingOptions.html +5 -5
- package/docs/types/services_geolocation.GeolocationInfoOptions.html +5 -5
- package/docs/types/services_geolocation.GeolocationResult.html +5 -5
- package/docs/types/services_staticMaps.AutomaticStaticMapOptions.html +5 -5
- package/docs/types/services_staticMaps.BoundedStaticMapOptions.html +5 -5
- package/docs/types/services_staticMaps.CenteredStaticMapOptions.html +5 -5
- package/docs/types/services_staticMaps.StaticMapBaseOptions.html +7 -7
- package/docs/types/services_staticMaps.StaticMapMarker.html +5 -5
- package/docs/variables/config.config.html +5 -5
- package/docs/variables/language.LanguageGeocoding.html +5 -5
- package/docs/variables/services_coordinates.coordinates.html +5 -5
- package/docs/variables/services_data.data.html +5 -5
- package/docs/variables/services_geocoding.geocoding.html +5 -5
- package/docs/variables/services_geolocation.geolocation.html +5 -5
- package/docs/variables/services_staticMaps.staticMaps.html +5 -5
- package/docsmd/README.md +145 -36
- package/docsmd/assets/custom.css +28 -1
- package/docsmd/classes/ClientConfig.md +5 -5
- package/docsmd/classes/MapStyleVariant.md +234 -0
- package/docsmd/classes/ReferenceMapStyle.md +169 -0
- package/docsmd/classes/ServiceError.md +3 -3
- package/examples/test-browser-umd.html +1 -1
- package/package.json +1 -1
- package/readme.md +86 -27
- package/src/index.ts +17 -0
- package/src/mapstyle.ts +874 -0
- package/src/services/staticMaps.ts +5 -4
- package/tsconfig.json +0 -1
- package/typedoc.css +28 -1
package/dist/maptiler-client.cjs
CHANGED
|
@@ -13,18 +13,37 @@ function tryGettingFetch() {
|
|
|
13
13
|
}
|
|
14
14
|
class ClientConfig {
|
|
15
15
|
constructor() {
|
|
16
|
+
/**
|
|
17
|
+
* MapTiler Cloud API key
|
|
18
|
+
*/
|
|
16
19
|
this._apiKey = "";
|
|
20
|
+
/**
|
|
21
|
+
* The fetch function. To be set if in Node < 18, otherwise
|
|
22
|
+
* will be automatically resolved.
|
|
23
|
+
*/
|
|
17
24
|
this._fetch = tryGettingFetch();
|
|
18
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Set the MapTiler Cloud API key
|
|
28
|
+
*/
|
|
19
29
|
set apiKey(k) {
|
|
20
30
|
this._apiKey = k;
|
|
21
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Get the MapTiler Cloud API key
|
|
34
|
+
*/
|
|
22
35
|
get apiKey() {
|
|
23
36
|
return this._apiKey;
|
|
24
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Set a the custom fetch function to replace the default one
|
|
40
|
+
*/
|
|
25
41
|
set fetch(f) {
|
|
26
42
|
this._fetch = f;
|
|
27
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Get the fetch fucntion
|
|
46
|
+
*/
|
|
28
47
|
get fetch() {
|
|
29
48
|
return this._fetch;
|
|
30
49
|
}
|
|
@@ -442,6 +461,547 @@ const data = {
|
|
|
442
461
|
get
|
|
443
462
|
};
|
|
444
463
|
|
|
464
|
+
function expandMapStyle(style) {
|
|
465
|
+
const maptilerDomainRegex = /^maptiler:\/\/(.*)/;
|
|
466
|
+
let match;
|
|
467
|
+
const trimmed = style.trim();
|
|
468
|
+
let expandedStyle;
|
|
469
|
+
if (trimmed.startsWith("http://") || trimmed.startsWith("https://")) {
|
|
470
|
+
expandedStyle = trimmed;
|
|
471
|
+
} else if ((match = maptilerDomainRegex.exec(trimmed)) !== null) {
|
|
472
|
+
expandedStyle = `https://api.maptiler.com/maps/${match[1]}/style.json`;
|
|
473
|
+
} else {
|
|
474
|
+
expandedStyle = `https://api.maptiler.com/maps/${trimmed}/style.json`;
|
|
475
|
+
}
|
|
476
|
+
return expandedStyle;
|
|
477
|
+
}
|
|
478
|
+
class MapStyleVariant {
|
|
479
|
+
constructor(name, variantType, id, referenceStyle, description, imageURL) {
|
|
480
|
+
this.name = name;
|
|
481
|
+
this.variantType = variantType;
|
|
482
|
+
this.id = id;
|
|
483
|
+
this.referenceStyle = referenceStyle;
|
|
484
|
+
this.description = description;
|
|
485
|
+
this.imageURL = imageURL;
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Get the human-friendly name
|
|
489
|
+
* @returns
|
|
490
|
+
*/
|
|
491
|
+
getName() {
|
|
492
|
+
return this.name;
|
|
493
|
+
}
|
|
494
|
+
getFullName() {
|
|
495
|
+
return `${this.referenceStyle.getName()} ${this.name}`;
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Get the variant type (eg. "DEFAULT", "DARK", "PASTEL", etc.)
|
|
499
|
+
* @returns
|
|
500
|
+
*/
|
|
501
|
+
getType() {
|
|
502
|
+
return this.variantType;
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* Get the MapTiler Cloud id
|
|
506
|
+
* @returns
|
|
507
|
+
*/
|
|
508
|
+
getId() {
|
|
509
|
+
return this.id;
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* Get the human-friendly description
|
|
513
|
+
*/
|
|
514
|
+
getDescription() {
|
|
515
|
+
return this.description;
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Get the reference style this variant belongs to
|
|
519
|
+
* @returns
|
|
520
|
+
*/
|
|
521
|
+
getReferenceStyle() {
|
|
522
|
+
return this.referenceStyle;
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Check if a variant of a given type exists for _this_ variants
|
|
526
|
+
* (eg. if this is a "DARK", then we can check if there is a "LIGHT" variant of it)
|
|
527
|
+
* @param variantType
|
|
528
|
+
* @returns
|
|
529
|
+
*/
|
|
530
|
+
hasVariant(variantType) {
|
|
531
|
+
return this.referenceStyle.hasVariant(variantType);
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Retrieve the variant of a given type. If not found, will return the "DEFAULT" variant.
|
|
535
|
+
* (eg. _this_ "DARK" variant does not have any "PASTEL" variant, then the "DEFAULT" is returned)
|
|
536
|
+
* @param variantType
|
|
537
|
+
* @returns
|
|
538
|
+
*/
|
|
539
|
+
getVariant(variantType) {
|
|
540
|
+
return this.referenceStyle.getVariant(variantType);
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* Get all the variants for _this_ variants, except _this_ current one
|
|
544
|
+
* @returns
|
|
545
|
+
*/
|
|
546
|
+
getVariants() {
|
|
547
|
+
return this.referenceStyle.getVariants().filter((v) => v !== this);
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Get the image URL that represent _this_ variant
|
|
551
|
+
* @returns
|
|
552
|
+
*/
|
|
553
|
+
getImageURL() {
|
|
554
|
+
return this.imageURL;
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* Get the style as usable by MapLibre, a string (URL) or a plain style description (StyleSpecification)
|
|
558
|
+
* @returns
|
|
559
|
+
*/
|
|
560
|
+
getExpandedStyleURL() {
|
|
561
|
+
return expandMapStyle(this.getId());
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
class ReferenceMapStyle {
|
|
565
|
+
constructor(name, id) {
|
|
566
|
+
this.name = name;
|
|
567
|
+
this.id = id;
|
|
568
|
+
/**
|
|
569
|
+
* Variants that belong to this reference style, key being the reference type
|
|
570
|
+
*/
|
|
571
|
+
this.variants = {};
|
|
572
|
+
/**
|
|
573
|
+
* Variants that belong to this reference style, ordered by relevance
|
|
574
|
+
*/
|
|
575
|
+
this.orderedVariants = [];
|
|
576
|
+
}
|
|
577
|
+
/**
|
|
578
|
+
* Get the human-friendly name of this reference style
|
|
579
|
+
* @returns
|
|
580
|
+
*/
|
|
581
|
+
getName() {
|
|
582
|
+
return this.name;
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* Get the id of _this_ reference style
|
|
586
|
+
* @returns
|
|
587
|
+
*/
|
|
588
|
+
getId() {
|
|
589
|
+
return this.id;
|
|
590
|
+
}
|
|
591
|
+
/**
|
|
592
|
+
* Add a variant to _this_ reference style
|
|
593
|
+
* @param v
|
|
594
|
+
*/
|
|
595
|
+
addVariant(v) {
|
|
596
|
+
this.variants[v.getType()] = v;
|
|
597
|
+
this.orderedVariants.push(v);
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* Check if a given variant type exists for this reference style
|
|
601
|
+
* @param variantType
|
|
602
|
+
* @returns
|
|
603
|
+
*/
|
|
604
|
+
hasVariant(variantType) {
|
|
605
|
+
return variantType in this.variants;
|
|
606
|
+
}
|
|
607
|
+
/**
|
|
608
|
+
* Get a given variant. If the given type of variant does not exist for this reference style,
|
|
609
|
+
* then the most relevant default variant is returned instead
|
|
610
|
+
* @param variantType
|
|
611
|
+
* @returns
|
|
612
|
+
*/
|
|
613
|
+
getVariant(variantType) {
|
|
614
|
+
return variantType in this.variants ? this.variants[variantType] : this.orderedVariants[0];
|
|
615
|
+
}
|
|
616
|
+
/**
|
|
617
|
+
* Get the list of variants for this reference style
|
|
618
|
+
* @returns
|
|
619
|
+
*/
|
|
620
|
+
getVariants() {
|
|
621
|
+
return Object.values(this.variants);
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* Get the defualt variant for this reference style
|
|
625
|
+
* @returns
|
|
626
|
+
*/
|
|
627
|
+
getDefaultVariant() {
|
|
628
|
+
return this.orderedVariants[0];
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
const mapStylePresetList = [
|
|
632
|
+
{
|
|
633
|
+
referenceStyleID: "STREETS",
|
|
634
|
+
name: "Streets",
|
|
635
|
+
description: "",
|
|
636
|
+
variants: [
|
|
637
|
+
{
|
|
638
|
+
id: "streets-v2",
|
|
639
|
+
name: "Default",
|
|
640
|
+
variantType: "DEFAULT",
|
|
641
|
+
description: "",
|
|
642
|
+
imageURL: ""
|
|
643
|
+
},
|
|
644
|
+
{
|
|
645
|
+
id: "streets-v2-dark",
|
|
646
|
+
name: "Dark",
|
|
647
|
+
variantType: "DARK",
|
|
648
|
+
description: "",
|
|
649
|
+
imageURL: ""
|
|
650
|
+
},
|
|
651
|
+
{
|
|
652
|
+
id: "streets-v2-light",
|
|
653
|
+
name: "Light",
|
|
654
|
+
variantType: "LIGHT",
|
|
655
|
+
description: "",
|
|
656
|
+
imageURL: ""
|
|
657
|
+
},
|
|
658
|
+
{
|
|
659
|
+
id: "streets-v2-pastel",
|
|
660
|
+
name: "Pastel",
|
|
661
|
+
variantType: "PASTEL",
|
|
662
|
+
description: "",
|
|
663
|
+
imageURL: ""
|
|
664
|
+
}
|
|
665
|
+
]
|
|
666
|
+
},
|
|
667
|
+
{
|
|
668
|
+
referenceStyleID: "OUTDOOR",
|
|
669
|
+
name: "Outdoor",
|
|
670
|
+
description: "",
|
|
671
|
+
variants: [
|
|
672
|
+
{
|
|
673
|
+
id: "outdoor-v2",
|
|
674
|
+
name: "Default",
|
|
675
|
+
variantType: "DEFAULT",
|
|
676
|
+
description: "",
|
|
677
|
+
imageURL: ""
|
|
678
|
+
}
|
|
679
|
+
]
|
|
680
|
+
},
|
|
681
|
+
{
|
|
682
|
+
referenceStyleID: "WINTER",
|
|
683
|
+
name: "Winter",
|
|
684
|
+
description: "",
|
|
685
|
+
variants: [
|
|
686
|
+
{
|
|
687
|
+
id: "winter-v2",
|
|
688
|
+
name: "Winter",
|
|
689
|
+
variantType: "DEFAULT",
|
|
690
|
+
description: "",
|
|
691
|
+
imageURL: ""
|
|
692
|
+
}
|
|
693
|
+
]
|
|
694
|
+
},
|
|
695
|
+
{
|
|
696
|
+
referenceStyleID: "SATELLITE",
|
|
697
|
+
name: "Satellite",
|
|
698
|
+
description: "",
|
|
699
|
+
variants: [
|
|
700
|
+
{
|
|
701
|
+
id: "satellite",
|
|
702
|
+
name: "Default",
|
|
703
|
+
variantType: "DEFAULT",
|
|
704
|
+
description: "",
|
|
705
|
+
imageURL: ""
|
|
706
|
+
}
|
|
707
|
+
]
|
|
708
|
+
},
|
|
709
|
+
{
|
|
710
|
+
referenceStyleID: "HYBRID",
|
|
711
|
+
name: "Hybrid",
|
|
712
|
+
description: "",
|
|
713
|
+
variants: [
|
|
714
|
+
{
|
|
715
|
+
id: "hybrid",
|
|
716
|
+
name: "Default",
|
|
717
|
+
variantType: "DEFAULT",
|
|
718
|
+
description: "",
|
|
719
|
+
imageURL: ""
|
|
720
|
+
}
|
|
721
|
+
]
|
|
722
|
+
},
|
|
723
|
+
{
|
|
724
|
+
referenceStyleID: "BASIC",
|
|
725
|
+
name: "Basic",
|
|
726
|
+
description: "",
|
|
727
|
+
variants: [
|
|
728
|
+
{
|
|
729
|
+
id: "basic-v2",
|
|
730
|
+
name: "Default",
|
|
731
|
+
variantType: "DEFAULT",
|
|
732
|
+
description: "",
|
|
733
|
+
imageURL: ""
|
|
734
|
+
},
|
|
735
|
+
{
|
|
736
|
+
id: "basic-v2-dark",
|
|
737
|
+
name: "Dark",
|
|
738
|
+
variantType: "DARK",
|
|
739
|
+
description: "",
|
|
740
|
+
imageURL: ""
|
|
741
|
+
},
|
|
742
|
+
{
|
|
743
|
+
id: "basic-v2-light",
|
|
744
|
+
name: "Light",
|
|
745
|
+
variantType: "LIGHT",
|
|
746
|
+
description: "",
|
|
747
|
+
imageURL: ""
|
|
748
|
+
}
|
|
749
|
+
]
|
|
750
|
+
},
|
|
751
|
+
{
|
|
752
|
+
referenceStyleID: "BRIGHT",
|
|
753
|
+
name: "Bright",
|
|
754
|
+
description: "",
|
|
755
|
+
variants: [
|
|
756
|
+
{
|
|
757
|
+
id: "bright-v2",
|
|
758
|
+
name: "Default",
|
|
759
|
+
variantType: "DEFAULT",
|
|
760
|
+
description: "",
|
|
761
|
+
imageURL: ""
|
|
762
|
+
},
|
|
763
|
+
{
|
|
764
|
+
id: "bright-v2-dark",
|
|
765
|
+
name: "Dark",
|
|
766
|
+
variantType: "DARK",
|
|
767
|
+
description: "",
|
|
768
|
+
imageURL: ""
|
|
769
|
+
},
|
|
770
|
+
{
|
|
771
|
+
id: "bright-v2-light",
|
|
772
|
+
name: "Light",
|
|
773
|
+
variantType: "LIGHT",
|
|
774
|
+
description: "",
|
|
775
|
+
imageURL: ""
|
|
776
|
+
},
|
|
777
|
+
{
|
|
778
|
+
id: "bright-v2-pastel",
|
|
779
|
+
name: "Pastel",
|
|
780
|
+
variantType: "PASTEL",
|
|
781
|
+
description: "",
|
|
782
|
+
imageURL: ""
|
|
783
|
+
}
|
|
784
|
+
]
|
|
785
|
+
},
|
|
786
|
+
{
|
|
787
|
+
referenceStyleID: "OPENSTREETMAP",
|
|
788
|
+
name: "OpenStreetMap",
|
|
789
|
+
description: "",
|
|
790
|
+
variants: [
|
|
791
|
+
{
|
|
792
|
+
id: "openstreetmap",
|
|
793
|
+
name: "Default",
|
|
794
|
+
variantType: "DEFAULT",
|
|
795
|
+
description: "",
|
|
796
|
+
imageURL: ""
|
|
797
|
+
}
|
|
798
|
+
]
|
|
799
|
+
},
|
|
800
|
+
{
|
|
801
|
+
referenceStyleID: "TOPO",
|
|
802
|
+
name: "Topo",
|
|
803
|
+
description: "",
|
|
804
|
+
variants: [
|
|
805
|
+
{
|
|
806
|
+
id: "topo-v2",
|
|
807
|
+
name: "Default",
|
|
808
|
+
variantType: "DEFAULT",
|
|
809
|
+
description: "",
|
|
810
|
+
imageURL: ""
|
|
811
|
+
},
|
|
812
|
+
{
|
|
813
|
+
id: "topo-v2-shiny",
|
|
814
|
+
name: "Shiny",
|
|
815
|
+
variantType: "SHINY",
|
|
816
|
+
description: "",
|
|
817
|
+
imageURL: ""
|
|
818
|
+
},
|
|
819
|
+
{
|
|
820
|
+
id: "topo-v2-pastel",
|
|
821
|
+
name: "Pastel",
|
|
822
|
+
variantType: "PASTEL",
|
|
823
|
+
description: "",
|
|
824
|
+
imageURL: ""
|
|
825
|
+
},
|
|
826
|
+
{
|
|
827
|
+
id: "topo-v2-topographique",
|
|
828
|
+
name: "Topographique",
|
|
829
|
+
variantType: "TOPOGRAPHIQUE",
|
|
830
|
+
description: "",
|
|
831
|
+
imageURL: ""
|
|
832
|
+
}
|
|
833
|
+
]
|
|
834
|
+
},
|
|
835
|
+
{
|
|
836
|
+
referenceStyleID: "VOYAGER",
|
|
837
|
+
name: "Voyager",
|
|
838
|
+
description: "",
|
|
839
|
+
variants: [
|
|
840
|
+
{
|
|
841
|
+
id: "voyager-v2",
|
|
842
|
+
name: "Default",
|
|
843
|
+
variantType: "DEFAULT",
|
|
844
|
+
description: "",
|
|
845
|
+
imageURL: ""
|
|
846
|
+
},
|
|
847
|
+
{
|
|
848
|
+
id: "voyager-v2-darkmatter",
|
|
849
|
+
name: "Darkmatter",
|
|
850
|
+
variantType: "DARK",
|
|
851
|
+
description: "",
|
|
852
|
+
imageURL: ""
|
|
853
|
+
},
|
|
854
|
+
{
|
|
855
|
+
id: "voyager-v2-positron",
|
|
856
|
+
name: "Positron",
|
|
857
|
+
variantType: "LIGHT",
|
|
858
|
+
description: "",
|
|
859
|
+
imageURL: ""
|
|
860
|
+
},
|
|
861
|
+
{
|
|
862
|
+
id: "voyager-v2-vintage",
|
|
863
|
+
name: "Vintage",
|
|
864
|
+
variantType: "VINTAGE",
|
|
865
|
+
description: "",
|
|
866
|
+
imageURL: ""
|
|
867
|
+
}
|
|
868
|
+
]
|
|
869
|
+
},
|
|
870
|
+
{
|
|
871
|
+
referenceStyleID: "TONER",
|
|
872
|
+
name: "Toner",
|
|
873
|
+
description: "",
|
|
874
|
+
variants: [
|
|
875
|
+
{
|
|
876
|
+
id: "toner-v2",
|
|
877
|
+
name: "Default",
|
|
878
|
+
variantType: "DEFAULT",
|
|
879
|
+
description: "",
|
|
880
|
+
imageURL: ""
|
|
881
|
+
},
|
|
882
|
+
{
|
|
883
|
+
id: "toner-v2-background",
|
|
884
|
+
name: "Background",
|
|
885
|
+
variantType: "BACKGROUND",
|
|
886
|
+
description: "",
|
|
887
|
+
imageURL: ""
|
|
888
|
+
},
|
|
889
|
+
{
|
|
890
|
+
id: "toner-v2-lite",
|
|
891
|
+
name: "Lite",
|
|
892
|
+
variantType: "LITE",
|
|
893
|
+
description: "",
|
|
894
|
+
imageURL: ""
|
|
895
|
+
},
|
|
896
|
+
{
|
|
897
|
+
id: "toner-v2-lines",
|
|
898
|
+
name: "Lines",
|
|
899
|
+
variantType: "LINES",
|
|
900
|
+
description: "",
|
|
901
|
+
imageURL: ""
|
|
902
|
+
}
|
|
903
|
+
]
|
|
904
|
+
},
|
|
905
|
+
{
|
|
906
|
+
referenceStyleID: "STAGE",
|
|
907
|
+
name: "Stage",
|
|
908
|
+
description: "",
|
|
909
|
+
variants: [
|
|
910
|
+
{
|
|
911
|
+
id: "stage",
|
|
912
|
+
name: "Default",
|
|
913
|
+
variantType: "DEFAULT",
|
|
914
|
+
description: "",
|
|
915
|
+
imageURL: ""
|
|
916
|
+
},
|
|
917
|
+
{
|
|
918
|
+
id: "stage-dark",
|
|
919
|
+
name: "Dark",
|
|
920
|
+
variantType: "DARK",
|
|
921
|
+
description: "",
|
|
922
|
+
imageURL: ""
|
|
923
|
+
},
|
|
924
|
+
{
|
|
925
|
+
id: "stage-light",
|
|
926
|
+
name: "Light",
|
|
927
|
+
variantType: "LIGHT",
|
|
928
|
+
description: "",
|
|
929
|
+
imageURL: ""
|
|
930
|
+
}
|
|
931
|
+
]
|
|
932
|
+
},
|
|
933
|
+
{
|
|
934
|
+
referenceStyleID: "OCEAN",
|
|
935
|
+
name: "Ocean",
|
|
936
|
+
description: "",
|
|
937
|
+
variants: [
|
|
938
|
+
{
|
|
939
|
+
id: "ocean",
|
|
940
|
+
name: "Default",
|
|
941
|
+
variantType: "DEFAULT",
|
|
942
|
+
description: "",
|
|
943
|
+
imageURL: ""
|
|
944
|
+
}
|
|
945
|
+
]
|
|
946
|
+
}
|
|
947
|
+
];
|
|
948
|
+
function makeReferenceStyleProxy(referenceStyle) {
|
|
949
|
+
return new Proxy(referenceStyle, {
|
|
950
|
+
get(target, prop, receiver) {
|
|
951
|
+
if (target.hasVariant(prop)) {
|
|
952
|
+
return target.getVariant(prop);
|
|
953
|
+
}
|
|
954
|
+
if (prop.toString().toUpperCase() === prop) {
|
|
955
|
+
return referenceStyle.getDefaultVariant();
|
|
956
|
+
}
|
|
957
|
+
return Reflect.get(target, prop, receiver);
|
|
958
|
+
}
|
|
959
|
+
});
|
|
960
|
+
}
|
|
961
|
+
function buildMapStyles() {
|
|
962
|
+
const mapStyle = {};
|
|
963
|
+
for (let i = 0; i < mapStylePresetList.length; i += 1) {
|
|
964
|
+
const refStyleInfo = mapStylePresetList[i];
|
|
965
|
+
const refStyle = makeReferenceStyleProxy(
|
|
966
|
+
new ReferenceMapStyle(refStyleInfo.name, refStyleInfo.referenceStyleID)
|
|
967
|
+
);
|
|
968
|
+
for (let j = 0; j < refStyleInfo.variants.length; j += 1) {
|
|
969
|
+
const variantInfo = refStyleInfo.variants[j];
|
|
970
|
+
const variant = new MapStyleVariant(
|
|
971
|
+
variantInfo.name,
|
|
972
|
+
// name
|
|
973
|
+
variantInfo.variantType,
|
|
974
|
+
// variantType
|
|
975
|
+
variantInfo.id,
|
|
976
|
+
// id
|
|
977
|
+
refStyle,
|
|
978
|
+
// referenceStyle
|
|
979
|
+
variantInfo.description,
|
|
980
|
+
variantInfo.imageURL
|
|
981
|
+
// imageURL
|
|
982
|
+
);
|
|
983
|
+
refStyle.addVariant(variant);
|
|
984
|
+
}
|
|
985
|
+
mapStyle[refStyleInfo.referenceStyleID] = refStyle;
|
|
986
|
+
}
|
|
987
|
+
return mapStyle;
|
|
988
|
+
}
|
|
989
|
+
function styleToStyle(style) {
|
|
990
|
+
if (!style) {
|
|
991
|
+
return MapStyle[mapStylePresetList[0].referenceStyleID].getDefaultVariant().getId();
|
|
992
|
+
}
|
|
993
|
+
if (typeof style === "string" || style instanceof String) {
|
|
994
|
+
return style.trim().toLowerCase();
|
|
995
|
+
}
|
|
996
|
+
if (style instanceof MapStyleVariant) {
|
|
997
|
+
return style.getId();
|
|
998
|
+
}
|
|
999
|
+
if (style instanceof ReferenceMapStyle) {
|
|
1000
|
+
return style.getDefaultVariant().getId();
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
const MapStyle = buildMapStyles();
|
|
1004
|
+
|
|
445
1005
|
function getSqSegDist(p, p1, p2) {
|
|
446
1006
|
let x = p1[0], y = p1[1], dx = p2[0] - x, dy = p2[1] - y;
|
|
447
1007
|
if (dx !== 0 || dy !== 0) {
|
|
@@ -512,12 +1072,12 @@ function simplifyAndStringify(path, maxNbChar = 3e3) {
|
|
|
512
1072
|
return str;
|
|
513
1073
|
}
|
|
514
1074
|
function centered(center, zoom, options = {}) {
|
|
515
|
-
var _a, _b, _c, _d, _e
|
|
516
|
-
const style = (
|
|
1075
|
+
var _a, _b, _c, _d, _e;
|
|
1076
|
+
const style = styleToStyle(options.style);
|
|
517
1077
|
const scale = options.hiDPI ? "@2x" : "";
|
|
518
|
-
const format = (
|
|
519
|
-
let width = ~~((
|
|
520
|
-
let height = ~~((
|
|
1078
|
+
const format = (_a = options.format) != null ? _a : "png";
|
|
1079
|
+
let width = ~~((_b = options.width) != null ? _b : 1024);
|
|
1080
|
+
let height = ~~((_c = options.height) != null ? _c : 1024);
|
|
521
1081
|
if (options.hiDPI) {
|
|
522
1082
|
width = ~~(width / 2);
|
|
523
1083
|
height = ~~(height / 2);
|
|
@@ -547,7 +1107,7 @@ function centered(center, zoom, options = {}) {
|
|
|
547
1107
|
}
|
|
548
1108
|
if ("path" in options) {
|
|
549
1109
|
let pathStr = "";
|
|
550
|
-
pathStr += `fill:${(
|
|
1110
|
+
pathStr += `fill:${(_d = options.pathFillColor) != null ? _d : "none"}|`;
|
|
551
1111
|
if ("pathStrokeColor" in options) {
|
|
552
1112
|
pathStr += `stroke:${options.pathStrokeColor}|`;
|
|
553
1113
|
}
|
|
@@ -558,16 +1118,16 @@ function centered(center, zoom, options = {}) {
|
|
|
558
1118
|
pathStr += simplifyAndStringify(options.path);
|
|
559
1119
|
endpoint.searchParams.set("path", pathStr);
|
|
560
1120
|
}
|
|
561
|
-
endpoint.searchParams.set("key", (
|
|
1121
|
+
endpoint.searchParams.set("key", (_e = options.apiKey) != null ? _e : config.apiKey);
|
|
562
1122
|
return endpoint.toString();
|
|
563
1123
|
}
|
|
564
1124
|
function bounded(boundingBox, options = {}) {
|
|
565
|
-
var _a, _b, _c, _d, _e
|
|
566
|
-
const style = (
|
|
1125
|
+
var _a, _b, _c, _d, _e;
|
|
1126
|
+
const style = styleToStyle(options.style);
|
|
567
1127
|
const scale = options.hiDPI ? "@2x" : "";
|
|
568
|
-
const format = (
|
|
569
|
-
let width = ~~((
|
|
570
|
-
let height = ~~((
|
|
1128
|
+
const format = (_a = options.format) != null ? _a : "png";
|
|
1129
|
+
let width = ~~((_b = options.width) != null ? _b : 1024);
|
|
1130
|
+
let height = ~~((_c = options.height) != null ? _c : 1024);
|
|
571
1131
|
if (options.hiDPI) {
|
|
572
1132
|
width = ~~(width / 2);
|
|
573
1133
|
height = ~~(height / 2);
|
|
@@ -600,7 +1160,7 @@ function bounded(boundingBox, options = {}) {
|
|
|
600
1160
|
}
|
|
601
1161
|
if ("path" in options) {
|
|
602
1162
|
let pathStr = "";
|
|
603
|
-
pathStr += `fill:${(
|
|
1163
|
+
pathStr += `fill:${(_d = options.pathFillColor) != null ? _d : "none"}|`;
|
|
604
1164
|
if ("pathStrokeColor" in options) {
|
|
605
1165
|
pathStr += `stroke:${options.pathStrokeColor}|`;
|
|
606
1166
|
}
|
|
@@ -611,21 +1171,21 @@ function bounded(boundingBox, options = {}) {
|
|
|
611
1171
|
pathStr += simplifyAndStringify(options.path);
|
|
612
1172
|
endpoint.searchParams.set("path", pathStr);
|
|
613
1173
|
}
|
|
614
|
-
endpoint.searchParams.set("key", (
|
|
1174
|
+
endpoint.searchParams.set("key", (_e = options.apiKey) != null ? _e : config.apiKey);
|
|
615
1175
|
return endpoint.toString();
|
|
616
1176
|
}
|
|
617
1177
|
function automatic(options = {}) {
|
|
618
|
-
var _a, _b, _c, _d, _e
|
|
1178
|
+
var _a, _b, _c, _d, _e;
|
|
619
1179
|
if (!("markers" in options) && !("path" in options)) {
|
|
620
1180
|
throw new Error(
|
|
621
1181
|
"Automatic static maps require markers and/or path to be created."
|
|
622
1182
|
);
|
|
623
1183
|
}
|
|
624
|
-
const style = (
|
|
1184
|
+
const style = styleToStyle(options.style);
|
|
625
1185
|
const scale = options.hiDPI ? "@2x" : "";
|
|
626
|
-
const format = (
|
|
627
|
-
let width = ~~((
|
|
628
|
-
let height = ~~((
|
|
1186
|
+
const format = (_a = options.format) != null ? _a : "png";
|
|
1187
|
+
let width = ~~((_b = options.width) != null ? _b : 1024);
|
|
1188
|
+
let height = ~~((_c = options.height) != null ? _c : 1024);
|
|
629
1189
|
if (options.hiDPI) {
|
|
630
1190
|
width = ~~(width / 2);
|
|
631
1191
|
height = ~~(height / 2);
|
|
@@ -660,7 +1220,7 @@ function automatic(options = {}) {
|
|
|
660
1220
|
}
|
|
661
1221
|
if ("path" in options) {
|
|
662
1222
|
let pathStr = "";
|
|
663
|
-
pathStr += `fill:${(
|
|
1223
|
+
pathStr += `fill:${(_d = options.pathFillColor) != null ? _d : "none"}|`;
|
|
664
1224
|
if ("pathStrokeColor" in options) {
|
|
665
1225
|
pathStr += `stroke:${options.pathStrokeColor}|`;
|
|
666
1226
|
}
|
|
@@ -671,7 +1231,7 @@ function automatic(options = {}) {
|
|
|
671
1231
|
pathStr += simplifyAndStringify(options.path);
|
|
672
1232
|
endpoint.searchParams.set("path", pathStr);
|
|
673
1233
|
}
|
|
674
|
-
endpoint.searchParams.set("key", (
|
|
1234
|
+
endpoint.searchParams.set("key", (_e = options.apiKey) != null ? _e : config.apiKey);
|
|
675
1235
|
return endpoint.toString();
|
|
676
1236
|
}
|
|
677
1237
|
const staticMaps = {
|
|
@@ -682,11 +1242,16 @@ const staticMaps = {
|
|
|
682
1242
|
|
|
683
1243
|
exports.ClientConfig = ClientConfig;
|
|
684
1244
|
exports.LanguageGeocoding = LanguageGeocoding;
|
|
1245
|
+
exports.MapStyle = MapStyle;
|
|
1246
|
+
exports.MapStyleVariant = MapStyleVariant;
|
|
1247
|
+
exports.ReferenceMapStyle = ReferenceMapStyle;
|
|
685
1248
|
exports.ServiceError = ServiceError;
|
|
686
1249
|
exports.config = config;
|
|
687
1250
|
exports.coordinates = coordinates;
|
|
688
1251
|
exports.data = data;
|
|
1252
|
+
exports.expandMapStyle = expandMapStyle;
|
|
689
1253
|
exports.geocoding = geocoding;
|
|
690
1254
|
exports.geolocation = geolocation;
|
|
1255
|
+
exports.mapStylePresetList = mapStylePresetList;
|
|
691
1256
|
exports.staticMaps = staticMaps;
|
|
692
1257
|
//# sourceMappingURL=maptiler-client.cjs.map
|