@maptiler/client 1.0.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/.eslintrc.cjs +6 -0
- package/LICENSE +29 -0
- package/dist/maptiler-client.cjs +692 -0
- package/dist/maptiler-client.cjs.map +1 -0
- package/dist/maptiler-client.d.ts +702 -0
- package/dist/maptiler-client.min.mjs +1 -0
- package/dist/maptiler-client.mjs +680 -0
- package/dist/maptiler-client.mjs.map +1 -0
- package/dist/maptiler-client.umd.js +698 -0
- package/dist/maptiler-client.umd.js.map +1 -0
- package/dist/maptiler-client.umd.min.js +1 -0
- package/docs/.nojekyll +1 -0
- package/docs/assets/highlight.css +85 -0
- package/docs/assets/main.js +54 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1257 -0
- package/docs/classes/ClientConfig.html +122 -0
- package/docs/classes/ServiceError.html +93 -0
- package/docs/images/JS-logo.svg +4 -0
- package/docs/images/TS-logo.svg +6 -0
- package/docs/images/maptiler-client-logo.afdesign +0 -0
- package/docs/images/maptiler-client-logo.svg +75 -0
- package/docs/images/maptiler-logo.svg +23 -0
- package/docs/images/screenshots/static-bounded-europe-1024.png +0 -0
- package/docs/images/screenshots/static-bounded-europe-2048.png +0 -0
- package/docs/images/screenshots/static-bounded-portugal-1024x2048.png +0 -0
- package/docs/images/screenshots/static-bounded-portugal-2048x2048.png +0 -0
- package/docs/images/screenshots/static-with-path.png +0 -0
- package/docs/index.html +280 -0
- package/docs/modules.html +119 -0
- package/docs/types/AutomaticStaticMapOptions.html +80 -0
- package/docs/types/BoundedStaticMapOptions.html +80 -0
- package/docs/types/CenteredStaticMapOptions.html +80 -0
- package/docs/types/CoordinateExport.html +85 -0
- package/docs/types/CoordinateGrid.html +83 -0
- package/docs/types/CoordinateId.html +85 -0
- package/docs/types/CoordinateSearch.html +107 -0
- package/docs/types/CoordinateSearchResult.html +89 -0
- package/docs/types/CoordinateTransformResult.html +90 -0
- package/docs/types/CoordinateTransformation.html +103 -0
- package/docs/types/Coordinates.html +78 -0
- package/docs/types/CoordinatesSearchOptions.html +97 -0
- package/docs/types/CoordinatesTransformOptions.html +99 -0
- package/docs/types/FeatureHierarchy.html +89 -0
- package/docs/types/FetchFunction.html +93 -0
- package/docs/types/GeocodingFeature.html +78 -0
- package/docs/types/GeocodingOptions.html +97 -0
- package/docs/types/GeocodingSearchResult.html +95 -0
- package/docs/types/GeolocationInfoOptions.html +87 -0
- package/docs/types/GeolocationResult.html +150 -0
- package/docs/types/GetDataOptions.html +87 -0
- package/docs/types/LanguageGeocodingString.html +80 -0
- package/docs/types/ReverseGeocodingOptions.html +89 -0
- package/docs/types/StaticMapBaseOptions.html +176 -0
- package/docs/types/StaticMapMarker.html +80 -0
- package/docs/types/XYZ.html +87 -0
- package/docs/variables/LanguageGeocoding.html +193 -0
- package/docs/variables/config.html +80 -0
- package/docs/variables/coordinates-1.html +124 -0
- package/docs/variables/data.html +103 -0
- package/docs/variables/geocoding.html +239 -0
- package/docs/variables/geolocation.html +101 -0
- package/docs/variables/staticMaps.html +147 -0
- package/docsmd/.nojekyll +1 -0
- package/docsmd/README.md +756 -0
- package/docsmd/classes/ClientConfig.md +90 -0
- package/docsmd/classes/ServiceError.md +52 -0
- package/docsmd/images/JS-logo.svg +4 -0
- package/docsmd/images/TS-logo.svg +6 -0
- package/docsmd/images/maptiler-client-logo.afdesign +0 -0
- package/docsmd/images/maptiler-client-logo.svg +75 -0
- package/docsmd/images/maptiler-logo.svg +23 -0
- package/docsmd/images/screenshots/static-bounded-europe-1024.png +0 -0
- package/docsmd/images/screenshots/static-bounded-europe-2048.png +0 -0
- package/docsmd/images/screenshots/static-bounded-portugal-1024x2048.png +0 -0
- package/docsmd/images/screenshots/static-bounded-portugal-2048x2048.png +0 -0
- package/docsmd/images/screenshots/static-with-path.png +0 -0
- package/examples/test-browser-es.html +102 -0
- package/examples/test-browser-umd.html +89 -0
- package/examples/test-node.js +52 -0
- package/images/JS-logo.svg +4 -0
- package/images/TS-logo.svg +6 -0
- package/images/maptiler-client-logo.afdesign +0 -0
- package/images/maptiler-client-logo.svg +75 -0
- package/images/maptiler-logo.svg +23 -0
- package/images/screenshots/static-bounded-europe-1024.png +0 -0
- package/images/screenshots/static-bounded-europe-2048.png +0 -0
- package/images/screenshots/static-bounded-portugal-1024x2048.png +0 -0
- package/images/screenshots/static-bounded-portugal-2048x2048.png +0 -0
- package/images/screenshots/static-with-path.png +0 -0
- package/package.json +69 -0
- package/readme.md +287 -0
- package/rollup.config.js +142 -0
- package/src/callFetch.ts +18 -0
- package/src/config.ts +65 -0
- package/src/defaults.ts +11 -0
- package/src/index.ts +90 -0
- package/src/language.ts +87 -0
- package/src/services/ServiceError.ts +10 -0
- package/src/services/coordinates.ts +258 -0
- package/src/services/data.ts +63 -0
- package/src/services/geocoding.ts +239 -0
- package/src/services/geolocation.ts +139 -0
- package/src/services/simplify.ts +87 -0
- package/src/services/staticMaps.ts +462 -0
- package/tsconfig.json +10 -0
- package/typedoc.json +10 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
2
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
3
|
+
<svg width="100%" height="100%" viewBox="0 0 231 41" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
|
4
|
+
<g transform="matrix(1,0,0,1,-9.41979e-05,0.000178727)">
|
|
5
|
+
<g transform="matrix(1,0,0,1,-1.20801,-0.711928)">
|
|
6
|
+
<path d="M58.567,28.139L58.567,20.497C58.567,18.616 57.566,16.908 55.595,16.908C53.654,16.908 52.508,18.616 52.508,20.497L52.508,28.139L48.922,28.139L48.922,13.84L52.244,13.84L52.508,15.578C53.273,14.129 54.949,13.609 56.33,13.609C58.066,13.609 59.8,14.304 60.624,16.271C61.918,14.245 63.595,13.667 65.476,13.667C69.593,13.667 71.622,16.155 71.622,20.44L71.622,28.139L68.034,28.139L68.034,20.44C68.034,18.559 67.24,16.966 65.301,16.966C63.359,16.966 62.153,18.616 62.153,20.497L62.153,28.139L58.567,28.139Z" style="fill:rgb(51,51,89);fill-rule:nonzero;"/>
|
|
7
|
+
<path d="M86.765,13.87L90.206,13.87L90.206,28.139L86.824,28.139L86.647,26.056C85.825,27.734 83.561,28.543 81.943,28.573C77.651,28.603 74.474,25.997 74.474,20.989C74.474,16.069 77.798,13.493 82.033,13.522C83.973,13.522 85.824,14.419 86.647,15.838L86.765,13.87ZM78.062,20.989C78.062,23.71 79.973,25.331 82.355,25.331C88,25.331 88,16.677 82.355,16.677C79.973,16.677 78.062,18.269 78.062,20.989Z" style="fill:rgb(51,51,89);fill-rule:nonzero;"/>
|
|
8
|
+
<path d="M93.236,34.105L93.236,13.87L96.589,13.87L96.822,15.838C97.94,14.245 99.882,13.551 101.528,13.551C105.996,13.551 108.968,16.822 108.968,21.019C108.968,25.187 106.291,28.487 101.645,28.487C100.118,28.487 97.852,28.023 96.822,26.461L96.822,34.104L93.236,34.104L93.236,34.105ZM105.381,21.019C105.381,18.791 103.851,16.966 101.264,16.966C98.676,16.966 97.146,18.791 97.146,21.019C97.146,23.247 98.823,25.073 101.264,25.073C103.705,25.073 105.381,23.247 105.381,21.019Z" style="fill:rgb(51,51,89);fill-rule:nonzero;"/>
|
|
9
|
+
<path d="M115.378,9.528L115.378,13.84L120.319,13.84L120.319,15.026L115.378,15.026L115.378,23.739C115.378,25.679 115.791,27.04 118.055,27.04C118.76,27.04 119.554,26.808 120.289,26.461L120.789,27.617C119.877,28.054 118.965,28.342 118.055,28.342C114.968,28.342 113.967,26.547 113.967,23.74L113.967,15.027L110.879,15.027L110.879,13.84L113.967,13.84L113.967,9.672L115.378,9.528Z" style="fill:rgb(51,51,89);fill-rule:nonzero;"/>
|
|
10
|
+
<path d="M125.554,9.18C125.554,10.685 123.23,10.685 123.23,9.18C123.23,7.675 125.554,7.675 125.554,9.18ZM123.643,13.782L123.643,28.14L125.082,28.14L125.082,13.782L123.643,13.782Z" style="fill:rgb(51,51,89);fill-rule:nonzero;"/>
|
|
11
|
+
<rect x="129.199" y="7.878" width="1.441" height="20.261" style="fill:rgb(51,51,89);"/>
|
|
12
|
+
<path d="M153.488,13.84L153.547,16.389C154.459,14.448 156.518,13.696 158.37,13.696C159.459,13.667 160.515,13.956 161.486,14.536L160.839,15.693C160.076,15.23 159.221,15.027 158.37,15.027C155.663,15.057 153.576,17.198 153.576,19.804L153.576,28.14L152.135,28.14L152.135,13.84L153.488,13.84Z" style="fill:rgb(51,51,89);fill-rule:nonzero;"/>
|
|
13
|
+
<path d="M135.54,23.414C135.541,23.415 135.543,23.417 135.543,23.418L147.303,20.354C147.302,20.349 147.302,20.345 147.302,20.341L135.54,23.414Z" style="fill:rgb(51,51,89);fill-rule:nonzero;"/>
|
|
14
|
+
<path d="M141.214,27.28C138.654,27.28 136.461,25.701 135.543,23.458L135.535,23.458L135.542,23.457C135.542,23.456 135.541,23.455 135.54,23.454L147.301,20.38C147.301,20.385 147.302,20.389 147.302,20.394L148.555,20.068C148.049,16.446 144.956,13.658 141.214,13.658C137.12,13.658 133.802,16.996 133.802,21.113C133.802,25.23 137.12,28.569 141.214,28.569C144.276,28.569 146.905,26.7 148.035,24.037L146.855,23.532C145.921,25.734 143.747,27.28 141.214,27.28ZM135.083,21.113C135.083,17.708 137.828,14.946 141.214,14.946C143.862,14.946 146.117,16.634 146.976,18.999L135.16,22.085C135.11,21.768 135.083,21.444 135.083,21.113Z" style="fill:rgb(51,51,89);fill-rule:nonzero;"/>
|
|
15
|
+
</g>
|
|
16
|
+
<g transform="matrix(1,0,0,1,-1.20801,-0.711928)">
|
|
17
|
+
<path d="M11.965,33.743C14.023,35.769 19.5,41.264 19.497,41.269C19.477,41.305 24.938,35.908 27.113,33.768L19.526,26.3L11.965,33.743Z" style="fill:rgb(58,24,136);fill-rule:nonzero;"/>
|
|
18
|
+
<path d="M19.526,26.3L27.113,33.768C27.124,33.756 27.138,33.741 27.15,33.731L34.73,26.27L27.143,18.802L19.526,26.3Z" style="fill:rgb(3,161,196);fill-rule:nonzero;"/>
|
|
19
|
+
<path d="M34.73,26.27L34.749,26.25C38.942,22.123 38.945,15.435 34.762,11.302L27.144,18.802L34.73,26.27Z" style="fill:rgb(5,208,223);fill-rule:nonzero;"/>
|
|
20
|
+
<path d="M11.908,18.802L4.349,26.243C4.351,26.245 4.352,26.248 4.355,26.25L11.953,33.73C11.957,33.734 11.961,33.738 11.966,33.743L19.526,26.3L11.908,18.802Z" style="fill:rgb(118,31,232);fill-rule:nonzero;"/>
|
|
21
|
+
<path d="M19.526,11.303L27.143,18.802L34.762,11.303C34.755,11.298 34.753,11.295 34.749,11.29L27.15,3.81C27.149,3.808 27.146,3.806 27.144,3.804L19.526,11.303Z" style="fill:rgb(255,170,1);fill-rule:nonzero;"/>
|
|
22
|
+
<path d="M4.317,11.328C0.161,15.46 0.172,22.124 4.349,26.243L11.908,18.802L4.317,11.328Z" style="fill:rgb(241,23,93);fill-rule:nonzero;"/>
|
|
23
|
+
<path d="M19.526,11.303L11.934,3.829L4.355,11.29C4.341,11.303 4.33,11.317 4.316,11.329L11.908,18.802L19.526,11.303Z" style="fill:rgb(251,58,27);fill-rule:nonzero;"/>
|
|
24
|
+
<path d="M27.144,3.804C22.946,-0.321 16.148,-0.319 11.953,3.81L11.934,3.829L19.526,11.303L27.144,3.804Z" style="fill:rgb(251,201,53);fill-rule:nonzero;"/>
|
|
25
|
+
</g>
|
|
26
|
+
<g>
|
|
27
|
+
<g transform="matrix(1.45413,0,0,1,-169.409,0.0892285)">
|
|
28
|
+
<clipPath id="_clip1">
|
|
29
|
+
<path d="M231.731,-0.54L263.099,11.149L258.296,38.404L226.928,26.715L231.731,-0.54Z"/>
|
|
30
|
+
</clipPath>
|
|
31
|
+
<g clip-path="url(#_clip1)">
|
|
32
|
+
<path d="M270.382,12.81L232.413,12.81C231.562,12.81 230.871,13.815 230.871,15.052L230.871,25.472C230.871,26.692 231.552,27.683 232.391,27.683L270.382,27.683L270.382,12.81Z" style="fill:rgb(3,161,196);"/>
|
|
33
|
+
</g>
|
|
34
|
+
</g>
|
|
35
|
+
<g transform="matrix(0.364213,0,0,0.364213,-18.0413,0.200674)">
|
|
36
|
+
<g transform="matrix(30.2678,0,0,30.2678,514.098,66.0889)">
|
|
37
|
+
<path d="M0.558,-0.487C0.553,-0.508 0.545,-0.527 0.536,-0.544C0.527,-0.561 0.515,-0.576 0.5,-0.589C0.485,-0.602 0.468,-0.612 0.449,-0.619C0.429,-0.626 0.406,-0.629 0.38,-0.629C0.342,-0.629 0.309,-0.621 0.282,-0.606C0.254,-0.591 0.231,-0.57 0.214,-0.545C0.197,-0.519 0.184,-0.49 0.176,-0.457C0.167,-0.424 0.163,-0.391 0.163,-0.357C0.163,-0.323 0.167,-0.29 0.176,-0.257C0.184,-0.224 0.197,-0.195 0.214,-0.17C0.231,-0.144 0.254,-0.123 0.282,-0.108C0.309,-0.093 0.342,-0.085 0.38,-0.085C0.408,-0.085 0.433,-0.09 0.454,-0.1C0.475,-0.109 0.494,-0.123 0.509,-0.14C0.524,-0.157 0.536,-0.176 0.545,-0.199C0.554,-0.222 0.559,-0.246 0.562,-0.272L0.684,-0.272C0.681,-0.229 0.672,-0.19 0.657,-0.155C0.641,-0.12 0.62,-0.089 0.593,-0.064C0.566,-0.038 0.535,-0.018 0.499,-0.004C0.463,0.01 0.423,0.017 0.38,0.017C0.327,0.017 0.279,0.007 0.237,-0.013C0.194,-0.032 0.158,-0.059 0.129,-0.093C0.1,-0.127 0.077,-0.167 0.062,-0.212C0.046,-0.257 0.038,-0.306 0.038,-0.357C0.038,-0.408 0.046,-0.456 0.062,-0.501C0.077,-0.546 0.1,-0.586 0.129,-0.62C0.158,-0.654 0.194,-0.681 0.237,-0.701C0.279,-0.721 0.327,-0.731 0.38,-0.731C0.42,-0.731 0.458,-0.725 0.493,-0.715C0.528,-0.704 0.56,-0.688 0.587,-0.667C0.614,-0.646 0.635,-0.62 0.652,-0.59C0.669,-0.56 0.679,-0.526 0.683,-0.487L0.558,-0.487Z" style="fill:white;fill-rule:nonzero;"/>
|
|
38
|
+
</g>
|
|
39
|
+
<g transform="matrix(30.2678,0,0,30.2678,535.951,66.0889)">
|
|
40
|
+
<path d="M0.076,-0.714L0.201,-0.714L0.201,-0.108L0.564,-0.108L0.564,-0L0.076,-0L0.076,-0.714Z" style="fill:white;fill-rule:nonzero;"/>
|
|
41
|
+
</g>
|
|
42
|
+
<g transform="matrix(30.2678,0,0,30.2678,553.325,66.0889)">
|
|
43
|
+
<rect x="0.076" y="-0.714" width="0.125" height="0.714" style="fill:white;fill-rule:nonzero;"/>
|
|
44
|
+
</g>
|
|
45
|
+
<g transform="matrix(30.2678,0,0,30.2678,561.74,66.0889)">
|
|
46
|
+
<path d="M0.076,-0.714L0.59,-0.714L0.59,-0.606L0.201,-0.606L0.201,-0.419L0.561,-0.419L0.561,-0.317L0.201,-0.317L0.201,-0.108L0.597,-0.108L0.597,-0L0.076,-0L0.076,-0.714Z" style="fill:white;fill-rule:nonzero;"/>
|
|
47
|
+
</g>
|
|
48
|
+
<g transform="matrix(30.2678,0,0,30.2678,580.808,66.0889)">
|
|
49
|
+
<path d="M0.071,-0.714L0.203,-0.714L0.529,-0.188L0.531,-0.188L0.531,-0.714L0.65,-0.714L0.65,-0L0.518,-0L0.193,-0.525L0.19,-0.525L0.19,-0L0.071,-0L0.071,-0.714Z" style="fill:white;fill-rule:nonzero;"/>
|
|
50
|
+
</g>
|
|
51
|
+
<g transform="matrix(30.2678,0,0,30.2678,602.662,66.0889)">
|
|
52
|
+
<path d="M0.008,-0.714L0.586,-0.714L0.586,-0.606L0.359,-0.606L0.359,-0L0.234,-0L0.234,-0.606L0.008,-0.606L0.008,-0.714Z" style="fill:white;fill-rule:nonzero;"/>
|
|
53
|
+
</g>
|
|
54
|
+
</g>
|
|
55
|
+
</g>
|
|
56
|
+
<g transform="matrix(1,0,0,1,-4.85769,0)">
|
|
57
|
+
<g transform="matrix(-1.1073,-1.35605e-16,1.40521e-16,-1.14744,491.39,43.567)">
|
|
58
|
+
<clipPath id="_clip2">
|
|
59
|
+
<path d="M222.883,26.693L244.255,31.978L249.737,11.334L228.365,6.049L222.883,26.693Z"/>
|
|
60
|
+
</clipPath>
|
|
61
|
+
<g clip-path="url(#_clip2)">
|
|
62
|
+
<path d="M270.382,12.81L233.848,12.81C232.205,12.81 230.871,14.097 230.871,15.683L230.871,24.808C230.871,26.395 232.206,27.683 233.85,27.683L270.382,27.683L270.382,12.81Z" style="fill:rgb(251,201,53);"/>
|
|
63
|
+
</g>
|
|
64
|
+
</g>
|
|
65
|
+
<g transform="matrix(0.364213,0,0,0.364213,32.4999,0.200674)">
|
|
66
|
+
<g transform="matrix(30.2678,0,0,30.2678,514.098,66.0889)">
|
|
67
|
+
<path d="M0.461,-0.23C0.461,-0.199 0.458,-0.168 0.453,-0.139C0.448,-0.11 0.437,-0.083 0.421,-0.06C0.404,-0.037 0.381,-0.018 0.35,-0.004C0.319,0.01 0.277,0.017 0.226,0.017C0.188,0.017 0.156,0.011 0.129,-0.001C0.102,-0.012 0.08,-0.028 0.063,-0.049C0.046,-0.069 0.033,-0.093 0.025,-0.121C0.017,-0.149 0.013,-0.179 0.013,-0.212L0.013,-0.25L0.138,-0.25L0.138,-0.213C0.138,-0.172 0.145,-0.141 0.159,-0.119C0.172,-0.096 0.198,-0.085 0.236,-0.085C0.256,-0.085 0.273,-0.088 0.286,-0.094C0.299,-0.1 0.309,-0.109 0.317,-0.121C0.324,-0.132 0.329,-0.147 0.332,-0.164C0.335,-0.181 0.336,-0.201 0.336,-0.223L0.336,-0.714L0.461,-0.714L0.461,-0.23Z" style="fill:white;fill-rule:nonzero;"/>
|
|
68
|
+
</g>
|
|
69
|
+
<g transform="matrix(30.2678,0,0,30.2678,530.352,66.0889)">
|
|
70
|
+
<path d="M0.158,-0.238C0.158,-0.211 0.163,-0.187 0.172,-0.168C0.181,-0.149 0.194,-0.133 0.211,-0.121C0.228,-0.108 0.247,-0.099 0.269,-0.094C0.29,-0.088 0.314,-0.085 0.339,-0.085C0.366,-0.085 0.39,-0.088 0.409,-0.095C0.428,-0.101 0.444,-0.109 0.456,-0.119C0.468,-0.129 0.477,-0.14 0.482,-0.154C0.487,-0.167 0.49,-0.18 0.49,-0.193C0.49,-0.22 0.484,-0.241 0.472,-0.254C0.459,-0.267 0.446,-0.276 0.431,-0.281C0.406,-0.29 0.376,-0.299 0.343,-0.308C0.309,-0.316 0.267,-0.327 0.218,-0.34C0.187,-0.348 0.162,-0.359 0.142,-0.372C0.121,-0.385 0.105,-0.399 0.093,-0.415C0.081,-0.431 0.073,-0.448 0.068,-0.466C0.063,-0.484 0.06,-0.502 0.06,-0.521C0.06,-0.557 0.068,-0.588 0.083,-0.615C0.097,-0.641 0.117,-0.663 0.142,-0.68C0.167,-0.697 0.195,-0.71 0.226,-0.719C0.257,-0.727 0.289,-0.731 0.321,-0.731C0.358,-0.731 0.393,-0.726 0.427,-0.717C0.46,-0.707 0.489,-0.692 0.514,-0.673C0.539,-0.654 0.558,-0.63 0.573,-0.602C0.588,-0.573 0.595,-0.54 0.595,-0.503L0.47,-0.503C0.467,-0.549 0.451,-0.582 0.423,-0.601C0.395,-0.62 0.359,-0.629 0.316,-0.629C0.301,-0.629 0.286,-0.628 0.271,-0.625C0.256,-0.622 0.242,-0.616 0.229,-0.61C0.216,-0.603 0.206,-0.593 0.198,-0.581C0.189,-0.569 0.185,-0.554 0.185,-0.536C0.185,-0.511 0.193,-0.491 0.209,-0.477C0.224,-0.462 0.245,-0.451 0.27,-0.444C0.273,-0.443 0.283,-0.44 0.302,-0.436C0.32,-0.431 0.34,-0.425 0.363,-0.419C0.386,-0.413 0.408,-0.407 0.43,-0.402C0.451,-0.396 0.467,-0.392 0.476,-0.389C0.499,-0.382 0.52,-0.372 0.537,-0.359C0.554,-0.346 0.569,-0.332 0.581,-0.316C0.592,-0.299 0.601,-0.282 0.607,-0.263C0.612,-0.244 0.615,-0.226 0.615,-0.207C0.615,-0.167 0.607,-0.133 0.591,-0.105C0.574,-0.076 0.553,-0.053 0.526,-0.035C0.499,-0.017 0.469,-0.004 0.435,0.005C0.401,0.013 0.366,0.017 0.331,0.017C0.29,0.017 0.252,0.012 0.216,0.002C0.18,-0.008 0.149,-0.023 0.122,-0.044C0.095,-0.065 0.074,-0.091 0.058,-0.124C0.042,-0.156 0.034,-0.194 0.033,-0.238L0.158,-0.238Z" style="fill:white;fill-rule:nonzero;"/>
|
|
71
|
+
</g>
|
|
72
|
+
</g>
|
|
73
|
+
</g>
|
|
74
|
+
</g>
|
|
75
|
+
</svg>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
2
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
3
|
+
<svg width="100%" height="100%" viewBox="0 0 161 41" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
|
4
|
+
<g transform="matrix(1,0,0,1,-1.20801,-0.711928)">
|
|
5
|
+
<path d="M11.965,33.743C14.023,35.769 19.5,41.264 19.497,41.269C19.477,41.305 24.938,35.908 27.113,33.768L19.526,26.3L11.965,33.743Z" style="fill:rgb(58,24,136);fill-rule:nonzero;"/>
|
|
6
|
+
<path d="M19.526,26.3L27.113,33.768C27.124,33.756 27.138,33.741 27.15,33.731L34.73,26.27L27.143,18.802L19.526,26.3Z" style="fill:rgb(3,161,196);fill-rule:nonzero;"/>
|
|
7
|
+
<path d="M34.73,26.27L34.749,26.25C38.942,22.123 38.945,15.435 34.762,11.302L27.144,18.802L34.73,26.27Z" style="fill:rgb(5,208,223);fill-rule:nonzero;"/>
|
|
8
|
+
<path d="M11.908,18.802L4.349,26.243C4.351,26.245 4.352,26.248 4.355,26.25L11.953,33.73C11.957,33.734 11.961,33.738 11.966,33.743L19.526,26.3L11.908,18.802Z" style="fill:rgb(118,31,232);fill-rule:nonzero;"/>
|
|
9
|
+
<path d="M19.526,11.303L27.143,18.802L34.762,11.303C34.755,11.298 34.753,11.295 34.749,11.29L27.15,3.81C27.149,3.808 27.146,3.806 27.144,3.804L19.526,11.303Z" style="fill:rgb(255,170,1);fill-rule:nonzero;"/>
|
|
10
|
+
<path d="M4.317,11.328C0.161,15.46 0.172,22.124 4.349,26.243L11.908,18.802L4.317,11.328Z" style="fill:rgb(241,23,93);fill-rule:nonzero;"/>
|
|
11
|
+
<path d="M19.526,11.303L11.934,3.829L4.355,11.29C4.341,11.303 4.33,11.317 4.316,11.329L11.908,18.802L19.526,11.303Z" style="fill:rgb(251,58,27);fill-rule:nonzero;"/>
|
|
12
|
+
<path d="M27.144,3.804C22.946,-0.321 16.148,-0.319 11.953,3.81L11.934,3.829L19.526,11.303L27.144,3.804Z" style="fill:rgb(251,201,53);fill-rule:nonzero;"/>
|
|
13
|
+
<path d="M58.567,28.139L58.567,20.497C58.567,18.616 57.566,16.908 55.595,16.908C53.654,16.908 52.508,18.616 52.508,20.497L52.508,28.139L48.922,28.139L48.922,13.84L52.244,13.84L52.508,15.578C53.273,14.129 54.949,13.609 56.33,13.609C58.066,13.609 59.8,14.304 60.624,16.271C61.918,14.245 63.595,13.667 65.476,13.667C69.593,13.667 71.622,16.155 71.622,20.44L71.622,28.139L68.034,28.139L68.034,20.44C68.034,18.559 67.24,16.966 65.301,16.966C63.359,16.966 62.153,18.616 62.153,20.497L62.153,28.139L58.567,28.139Z" style="fill-rule:nonzero;"/>
|
|
14
|
+
<path d="M86.765,13.87L90.206,13.87L90.206,28.139L86.824,28.139L86.647,26.056C85.825,27.734 83.561,28.543 81.943,28.573C77.651,28.603 74.474,25.997 74.474,20.989C74.474,16.069 77.798,13.493 82.033,13.522C83.973,13.522 85.824,14.419 86.647,15.838L86.765,13.87ZM78.062,20.989C78.062,23.71 79.973,25.331 82.355,25.331C88,25.331 88,16.677 82.355,16.677C79.973,16.677 78.062,18.269 78.062,20.989Z" style="fill-rule:nonzero;"/>
|
|
15
|
+
<path d="M93.236,34.105L93.236,13.87L96.589,13.87L96.822,15.838C97.94,14.245 99.882,13.551 101.528,13.551C105.996,13.551 108.968,16.822 108.968,21.019C108.968,25.187 106.291,28.487 101.645,28.487C100.118,28.487 97.852,28.023 96.822,26.461L96.822,34.104L93.236,34.104L93.236,34.105ZM105.381,21.019C105.381,18.791 103.851,16.966 101.264,16.966C98.676,16.966 97.146,18.791 97.146,21.019C97.146,23.247 98.823,25.073 101.264,25.073C103.705,25.073 105.381,23.247 105.381,21.019Z" style="fill-rule:nonzero;"/>
|
|
16
|
+
<path d="M115.378,9.528L115.378,13.84L120.319,13.84L120.319,15.026L115.378,15.026L115.378,23.739C115.378,25.679 115.791,27.04 118.055,27.04C118.76,27.04 119.554,26.808 120.289,26.461L120.789,27.617C119.877,28.054 118.965,28.342 118.055,28.342C114.968,28.342 113.967,26.547 113.967,23.74L113.967,15.027L110.879,15.027L110.879,13.84L113.967,13.84L113.967,9.672L115.378,9.528Z" style="fill-rule:nonzero;"/>
|
|
17
|
+
<path d="M125.554,9.18C125.554,10.685 123.23,10.685 123.23,9.18C123.23,7.675 125.554,7.675 125.554,9.18ZM123.643,13.782L123.643,28.14L125.082,28.14L125.082,13.782L123.643,13.782Z" style="fill-rule:nonzero;"/>
|
|
18
|
+
<rect x="129.199" y="7.878" width="1.441" height="20.261" style="fill-rule:nonzero;"/>
|
|
19
|
+
<path d="M153.488,13.84L153.547,16.389C154.459,14.448 156.518,13.696 158.37,13.696C159.459,13.667 160.515,13.956 161.486,14.536L160.839,15.693C160.076,15.23 159.221,15.027 158.37,15.027C155.663,15.057 153.576,17.198 153.576,19.804L153.576,28.14L152.135,28.14L152.135,13.84L153.488,13.84Z" style="fill-rule:nonzero;"/>
|
|
20
|
+
<path d="M135.54,23.414C135.541,23.415 135.543,23.417 135.543,23.418L147.303,20.354C147.302,20.349 147.302,20.345 147.302,20.341L135.54,23.414Z" style="fill-rule:nonzero;"/>
|
|
21
|
+
<path d="M141.214,27.28C138.654,27.28 136.461,25.701 135.543,23.458L135.535,23.458L135.542,23.457C135.542,23.456 135.541,23.455 135.54,23.454L147.301,20.38C147.301,20.385 147.302,20.389 147.302,20.394L148.555,20.068C148.049,16.446 144.956,13.658 141.214,13.658C137.12,13.658 133.802,16.996 133.802,21.113C133.802,25.23 137.12,28.569 141.214,28.569C144.276,28.569 146.905,26.7 148.035,24.037L146.855,23.532C145.921,25.734 143.747,27.28 141.214,27.28ZM135.083,21.113C135.083,17.708 137.828,14.946 141.214,14.946C143.862,14.946 146.117,16.634 146.976,18.999L135.16,22.085C135.11,21.768 135.083,21.444 135.083,21.113Z" style="fill-rule:nonzero;"/>
|
|
22
|
+
</g>
|
|
23
|
+
</svg>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@maptiler/client",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Javascript & Typescript wrapper to MapTiler Cloud API",
|
|
5
|
+
"module": "dist/maptiler-client.mjs",
|
|
6
|
+
"types": "dist/maptiler-client.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"author": "MapTiler",
|
|
9
|
+
"homepage": "https://github.com/maptiler/maptiler-client-js",
|
|
10
|
+
"exports": {
|
|
11
|
+
"import": "./dist/maptiler-client.mjs",
|
|
12
|
+
"require": "./dist/maptiler-client.cjs"
|
|
13
|
+
},
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public",
|
|
16
|
+
"registry": "https://registry.npmjs.org/"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"geocoding",
|
|
20
|
+
"reverse geocoding",
|
|
21
|
+
"coordinates",
|
|
22
|
+
"CRS",
|
|
23
|
+
"geolocation",
|
|
24
|
+
"static maps",
|
|
25
|
+
"maptiler",
|
|
26
|
+
"map",
|
|
27
|
+
"REST API",
|
|
28
|
+
"wrapper",
|
|
29
|
+
"cloud"
|
|
30
|
+
],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "rm -rf dist/*; NODE_ENV=production rollup -c",
|
|
33
|
+
"dev": "rm -rf dist/*; NODE_ENV=development rollup -c -w",
|
|
34
|
+
"devserve": "rm -rf dist/*; NODE_ENV=development rollup -c -w & serve && fg",
|
|
35
|
+
"format": "prettier --write \"src/**/*.{js,ts,tsx}\"",
|
|
36
|
+
"lint": "eslint --fix \"src/**/*.{js,ts}\"",
|
|
37
|
+
"docmd": "rm -rf docsmd/*; typedoc --readme none --plugin typedoc-plugin-markdown --out docsmd src/index.ts; cp -r images docsmd/",
|
|
38
|
+
"dochtml": "rm -rf docs/*; typedoc --plugin none --out docs src/index.ts; cp -r images docs/",
|
|
39
|
+
"doc": "npm run docmd; npm run dochtml",
|
|
40
|
+
"prepare": "npm run format; npm run lint; npm run build; npm run doc"
|
|
41
|
+
},
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "https://github.com/maptiler/maptiler-client-js.git"
|
|
45
|
+
},
|
|
46
|
+
"license": "BSD-3-Clause",
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@rollup/plugin-commonjs": "^22.0.2",
|
|
49
|
+
"@rollup/plugin-json": "^5.0.1",
|
|
50
|
+
"@rollup/plugin-node-resolve": "^14.1.0",
|
|
51
|
+
"@typescript-eslint/eslint-plugin": "^5.42.1",
|
|
52
|
+
"@typescript-eslint/parser": "^5.42.1",
|
|
53
|
+
"eslint": "^8.27.0",
|
|
54
|
+
"prettier": "^2.7.1",
|
|
55
|
+
"rollup": "^2.79.0",
|
|
56
|
+
"rollup-plugin-dts": "^4.2.2",
|
|
57
|
+
"rollup-plugin-esbuild": "^4.10.1",
|
|
58
|
+
"rollup-plugin-node-globals": "^1.4.0",
|
|
59
|
+
"rollup-plugin-string": "^3.0.0",
|
|
60
|
+
"rollup-plugin-swc": "^0.2.1",
|
|
61
|
+
"serve": "^14.1.1",
|
|
62
|
+
"typedoc": "^0.23.21",
|
|
63
|
+
"typedoc-plugin-markdown": "^3.13.6",
|
|
64
|
+
"typescript": "^4.8.3"
|
|
65
|
+
},
|
|
66
|
+
"dependencies": {
|
|
67
|
+
"@types/geojson": "^7946.0.10"
|
|
68
|
+
}
|
|
69
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="images/maptiler-client-logo.svg" width="400px">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center" style="color: #AAA">
|
|
6
|
+
The Javascript & TypeScript API client library to enjoy <a href="https://www.maptiler.com/cloud/">MapTiler Cloud</a>'s <br>services such as geocoding, geolocation and more!
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<img src="images/JS-logo.svg" width="20px">
|
|
11
|
+
<img src="images/TS-logo.svg" width="20px">
|
|
12
|
+
<img src="https://img.shields.io/npm/v/@maptiler/client"></img>
|
|
13
|
+
<img src="https://img.shields.io/twitter/follow/maptiler?style=social"></img>
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
# What and why?
|
|
17
|
+
The **MapTiler Client JS** exposes a number of handy functions that wrap API call to [MapTiler Cloud API services](https://docs.maptiler.com/cloud/api), such as:
|
|
18
|
+
- Geocoding forward and reverse
|
|
19
|
+
- Geolocation from visitor's IP address
|
|
20
|
+
- Coordidinate systems search and tranform
|
|
21
|
+
- User data fetching as GeoJSON
|
|
22
|
+
- Static maps of all sorts
|
|
23
|
+
|
|
24
|
+
The project is entirely written in TypeScript and all the function arguments are nicely documented and typed.
|
|
25
|
+
|
|
26
|
+
> 📣 *__Note:__* If you need *this* API wrapper **AND** a complete SDK to display beautiful interactive maps, then checkout [MapTiler SDK JS](https://github.com/maptiler/maptiler-sdk-js), it contains it all!
|
|
27
|
+
|
|
28
|
+
# Install
|
|
29
|
+
```shell
|
|
30
|
+
npm install --save @maptiler/client
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
# API documentation
|
|
34
|
+
In addition to the details and examples provided in this readme, check out the [complete API documentation](docs/README.md)).
|
|
35
|
+
|
|
36
|
+
# Quick start
|
|
37
|
+
```ts
|
|
38
|
+
// Import the whole library
|
|
39
|
+
import * as maptilerClient from '@maptiler/client';
|
|
40
|
+
|
|
41
|
+
// Or import only the bits you need
|
|
42
|
+
import {
|
|
43
|
+
config,
|
|
44
|
+
geocoding,
|
|
45
|
+
geolocation,
|
|
46
|
+
coordinates,
|
|
47
|
+
data,
|
|
48
|
+
staticMaps,
|
|
49
|
+
} from '@maptiler/client';
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The [examples](examples/) folder includes are featuring usages for **NodeJS**, **browser with UMD** and **browser with ES module**.
|
|
53
|
+
|
|
54
|
+
# Easy access to MapTiler Cloud API
|
|
55
|
+
Here is the list of service wrapper functions that are built-in:
|
|
56
|
+
|
|
57
|
+
## 🔍 Geocoding
|
|
58
|
+
### Forward
|
|
59
|
+
You want to know the longitude and latitude of a specific place, use the forward geocoding:
|
|
60
|
+
```ts
|
|
61
|
+
// in an async function, or as a 'thenable':
|
|
62
|
+
const result = await maptilerClient.geocoding.forward('paris');
|
|
63
|
+
```
|
|
64
|
+
You can provide some options such as:
|
|
65
|
+
- the proximity, given a lon-lat position, to sort the results
|
|
66
|
+
- one of more languages to get the results into
|
|
67
|
+
- a bounding geo box, to restrict the search to a given window
|
|
68
|
+
|
|
69
|
+
Read more about forward geocoding on our official [API documentation](https://docs.maptiler.com/cloud/api/geocoding/#search-by-name-forward).
|
|
70
|
+
|
|
71
|
+
### Reverse
|
|
72
|
+
You wan to tknow the name of a place, given a longitude-latitude? Use the reverse geocoding:
|
|
73
|
+
```ts
|
|
74
|
+
// in an async function, or as a 'thenable':
|
|
75
|
+
const result = await maptilerClient.geocoding.reverse([6.249638, 46.402056]);
|
|
76
|
+
```
|
|
77
|
+
The same option object as the forward geocoding can be provided.
|
|
78
|
+
|
|
79
|
+
Read more about reverse geocoding on our official [API documentation](https://docs.maptiler.com/cloud/api/geocoding/#search-by-coordinates-reverse).
|
|
80
|
+
|
|
81
|
+
### Language
|
|
82
|
+
For both *forward* and *reverse* geocoding, this library provides a list of supported languages as shorthands to [ISO language codes](https://en.wikipedia.org/wiki/ISO_639-1). The result will be provided in multiple languages if the `language` options is an array:
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
const result = await maptilerClient.geocoding.forward('paris', {language: [maptilerClient.geocoding.languages.SPANISH, maptilerClient.geocoding.languages.KOREAN]})
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
The special language `AUTO` will detect the plateform/browser prefered language.
|
|
89
|
+
|
|
90
|
+
## 🕵️♂️ Geolocation
|
|
91
|
+
The geolocation service provides an accurate location insight of a website visitor using its IP address.
|
|
92
|
+
|
|
93
|
+
There is only a single function:
|
|
94
|
+
```ts
|
|
95
|
+
// in an async function, or as a 'thenable':
|
|
96
|
+
const result = await maptilerClient.geolocation.info();
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Read more about geolocation on our official [API documentation](https://docs.maptiler.com/cloud/api/geolocation/).
|
|
100
|
+
|
|
101
|
+
## 🌐 Coordinates
|
|
102
|
+
If you are already familiar with [epsg.io](https://epsg.io/) (created by MapTiler), then you may find convenient to access the details of more than 10 thousands of coordinate reference systems (CRS) programmatically, as well as transforming coordinates from one system to another!
|
|
103
|
+
|
|
104
|
+
### Search
|
|
105
|
+
The `search` lets you perform a query in a free form fashion. Here are some examples:
|
|
106
|
+
```ts
|
|
107
|
+
// in an async function, or as a 'thenable':
|
|
108
|
+
const resultA = await maptilerClient.coordinates.search('mercator');
|
|
109
|
+
const resultB = await maptilerClient.coordinates.search('plate carree');
|
|
110
|
+
const resultC = await maptilerClient.coordinates.search('france');
|
|
111
|
+
const resultD = await maptilerClient.coordinates.search('code:4326', {transformations: true}));
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
The `transformations` options retrieves a lot more details about the CRS that MapTiler API is able to transform to/from than just their IDs.
|
|
115
|
+
|
|
116
|
+
Read more about searching coordinate systems on our official [API documentation](https://docs.maptiler.com/cloud/api/coordinates/#search-coordinate-systems).
|
|
117
|
+
|
|
118
|
+
### Transform
|
|
119
|
+
Transforming a couple of coordinates from one system to another can be challenging, for example, most countries have their own official system, yet web mapping tools are more often than not exclusive to [WGS84](https://epsg.io/4326).
|
|
120
|
+
|
|
121
|
+
If not provided, both the source (`sourceCrs`) and the destination (`targetCrs`) are default to **EPSG:4326** (in other words, [WGS84](https://epsg.io/4326)). Here is how to use this feature:
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
// in an async function, or as a 'thenable':
|
|
125
|
+
|
|
126
|
+
// Providing one coordinate to transform, with a target CRS being EPSG:9793 (RGF93 v2 / Lambert-93, France official CRS)
|
|
127
|
+
const resultA = await maptilerClient.coordinates.transform([1, 45], {targetCrs: 9793})
|
|
128
|
+
|
|
129
|
+
// Using the same logic, we can pass up to 50 coordinates to be transformed
|
|
130
|
+
const resultB = await maptilerClient.coordinates.transform([[10, 48], [1, 45]], {targetCrs: 9793})
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Read more about transforming coordinates on our official [API documentation](https://docs.maptiler.com/cloud/api/coordinates/#transform-coordinates).
|
|
134
|
+
|
|
135
|
+
## 💽 Data
|
|
136
|
+
MapTiler Cloud give its users the possibility to [upload and create data](https://cloud.maptiler.com/data/), manually with a user interface or by uploading a GPX, GeoJSON, KML or shp file. A unique ID is associated to each dataset so that we can later on access it programmatically to retrieve a GeoJSON equivalent of it:
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
// in an async function, or as a 'thenable':
|
|
140
|
+
const result = await maptilerClient.data.get('my-dataset-unique-id')
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Since the result is a GeoJSON, it can easily be added to a `map` with `.addSource()` and `.addLayer()`.
|
|
144
|
+
|
|
145
|
+
## 🗺️ Static maps
|
|
146
|
+
Maptiler Cloud provides many possibilities for creating static maps as PNG, JPEG or WebP images. They all offer the possibilities to:
|
|
147
|
+
- Choose from one of the MapTiler style or your own
|
|
148
|
+
- Add markers with a custom icon (or default icon with custom color)
|
|
149
|
+
- Add path or polygon, with a parametric line width and color and a parametric filling color
|
|
150
|
+
|
|
151
|
+
Three modes are available: `centered`, `bounded` and `automatic`.
|
|
152
|
+
|
|
153
|
+
> 📣 *__important:__* Contrary to the geolocation/geocoding/coordinates/data service wrappers, the static maps function **does not** perform any query to the MapTiler API, instead they build the image URL. We took this decision because images are most likely going to be displayed in `<img src="path.png"></img>` markups and will naturaly be fetched by the web browser.
|
|
154
|
+
|
|
155
|
+
### Centered static maps
|
|
156
|
+
This type of map is centered on a longitude-latitude coordinate and the zoom level must also be provided (from `0`: very zoomed out, to `22`: very zoomed in).
|
|
157
|
+
Note that if a path or markers are provided, the framing of the map will not automatically adapt to include those (use the `automatic` mode for that).
|
|
158
|
+
|
|
159
|
+
```ts
|
|
160
|
+
const imageLink = maptiler.staticMaps.centered(
|
|
161
|
+
// center position (Boston)
|
|
162
|
+
[-71.06080, 42.362114],
|
|
163
|
+
|
|
164
|
+
// zoom level
|
|
165
|
+
12.5,
|
|
166
|
+
|
|
167
|
+
// Options
|
|
168
|
+
{
|
|
169
|
+
// Request a hiDPI/Retina image
|
|
170
|
+
hiDPI: true,
|
|
171
|
+
|
|
172
|
+
// Output image size
|
|
173
|
+
width: 1000,
|
|
174
|
+
height: 1000,
|
|
175
|
+
|
|
176
|
+
// Map style
|
|
177
|
+
style: 'streets-v2',
|
|
178
|
+
});
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Read more about centered static maps on our official [API documentation](https://docs.maptiler.com/cloud/api/static-maps/#center-based-image).
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
### Bounded static maps
|
|
185
|
+
This type of map requires a bounding box made of two points: the south-west bound and the north-east bound. The zoom level cannot be provided and is automatically deduced from the size of the bounding box.
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
const imageLink = maptiler.staticMaps.bounded(
|
|
189
|
+
// The bounding box on Europe
|
|
190
|
+
[
|
|
191
|
+
-24, // west bound (min x)
|
|
192
|
+
34.5, // south bound (min y)
|
|
193
|
+
32, // east bound (max x)
|
|
194
|
+
71, // north bound (max y)
|
|
195
|
+
],
|
|
196
|
+
|
|
197
|
+
// Options
|
|
198
|
+
{
|
|
199
|
+
hiDPI: true,
|
|
200
|
+
width: 2048,
|
|
201
|
+
height: 2048,
|
|
202
|
+
style: 'streets-v2',
|
|
203
|
+
|
|
204
|
+
// Extra space that will add around the bounding box, in percentage
|
|
205
|
+
// (0.1 = 10% is actually the dafault)
|
|
206
|
+
padding: 0.1
|
|
207
|
+
});
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
Since the zoom level cannot be provided, the level of details is dictated by the size of the output image. here is an example:
|
|
211
|
+
|
|
212
|
+
| `2048 x 2048` | `1024 x 1024` |
|
|
213
|
+
| :-----------: | :-----------: |
|
|
214
|
+
|  |  |
|
|
215
|
+
|
|
216
|
+
As you may notice, the geo bounding box could have very different proportions than the output image size. In the following example, we place the very same bounding box around Portugal, which has a this particular strip looking shape. We also add a `path` that repeats exactely the same bounding box to show the difference between the provided bounding box and the final image. We kept the default padding of 10%:
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
| `2048 x 2048` | `1024 x 2048` |
|
|
220
|
+
| :-----------: | :-----------: |
|
|
221
|
+
|  |  |
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
Read more about bounded static maps on our official [API documentation](https://docs.maptiler.com/cloud/api/static-maps/#bounds-based-image).
|
|
225
|
+
|
|
226
|
+
### Automatic static maps
|
|
227
|
+
As we have seen with centered and bounded maps, providing all the parameters is nice but can be cumbersome for the simplest use cases. This is why MapTiler Cloud also provides static maps that fits automatically whatever you need to place inside: path or markers.
|
|
228
|
+
|
|
229
|
+
In the following example, we are going to load a cycling track recorded by one of our team members in Montreal, Canada. The track, originally a GPX file, was pushed to MapTiler Data and is now made avalable as a GeoJSON:
|
|
230
|
+
|
|
231
|
+
```ts
|
|
232
|
+
// Fetching the GeoJSON
|
|
233
|
+
const bikeTrack = await maptilerClient.data.get('the-id-of-a-bike-track-in-montreal');
|
|
234
|
+
|
|
235
|
+
// Extracting the track points with the shape [[lng, lat], [lng, lat], ...]
|
|
236
|
+
const trackPoints = bikeTrack.features[0].geometry.coordinates[0]
|
|
237
|
+
.map(p => p.slice(0, 2));
|
|
238
|
+
|
|
239
|
+
const imageLink = maptiler.staticMaps.automatic({
|
|
240
|
+
// hiDPI/Retina precision
|
|
241
|
+
hiDPI: true,
|
|
242
|
+
|
|
243
|
+
// A farily large output image
|
|
244
|
+
width: 2048,
|
|
245
|
+
height: 1024 ,
|
|
246
|
+
|
|
247
|
+
// A grey style on which the track will pop!
|
|
248
|
+
style: 'streets-v2-light',
|
|
249
|
+
|
|
250
|
+
// Draw a path with the trackpoints
|
|
251
|
+
path: trackPoints,
|
|
252
|
+
|
|
253
|
+
// Adding a marker for the starting point, with a custom color (array of shape [lng, lat, color])
|
|
254
|
+
marker: [trackPoints[0][0], trackPoints[0][1], '#0a0'],
|
|
255
|
+
|
|
256
|
+
// Showing the track in red
|
|
257
|
+
pathStrokeColor: 'red',
|
|
258
|
+
});
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
And voila!
|
|
262
|
+
|
|
263
|
+

|
|
264
|
+
|
|
265
|
+
> 📣 *__Note:__* The GeoJSON for this track contains 9380 couples of coordinates, which is a lot! In order to send the track to MapTiler Cloud static maps API, the client simplifies the long paths while keeing a high degree of precision using a very fast [Ramer-Douglas-Peucker algorithm](https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm).
|
|
266
|
+
|
|
267
|
+
Read more about bounded static maps on our official [API documentation](https://docs.maptiler.com/cloud/api/static-maps/#auto-fitted-image).
|
|
268
|
+
|
|
269
|
+
# From NodeJS
|
|
270
|
+
NodeJS includes a stable `fetch()` function only from its version *18*, and this client does not contain a polyfill. If the `fetch()` function exists (browser or Node >= 18) then it is going to be resolved automatically, Yet, a custom `fetch()` function can be provided to the `config` object for Node < 18.
|
|
271
|
+
|
|
272
|
+
In [this NodeJS example](examples/test-node.js), you can see that the package [Node Fetch](https://www.npmjs.com/package/node-fetch) has been `npm install`ed and is passed to the config object of the *MapTiler Client*.
|
|
273
|
+
|
|
274
|
+
```js
|
|
275
|
+
import {
|
|
276
|
+
config,
|
|
277
|
+
// ...
|
|
278
|
+
} from '@maptiler/client';
|
|
279
|
+
|
|
280
|
+
// For this example to work, you must bring your own node-compatible fetch,
|
|
281
|
+
// unles you are using a version of Nodejs that already contains fetch (>=18)
|
|
282
|
+
import fetch from 'node-fetch';
|
|
283
|
+
|
|
284
|
+
config.fetch = fetch;
|
|
285
|
+
|
|
286
|
+
// ...
|
|
287
|
+
```
|
package/rollup.config.js
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import dts from "rollup-plugin-dts";
|
|
2
|
+
import esbuild from "rollup-plugin-esbuild";
|
|
3
|
+
import { nodeResolve } from "@rollup/plugin-node-resolve";
|
|
4
|
+
import globals from "rollup-plugin-node-globals";
|
|
5
|
+
import commonjs from "@rollup/plugin-commonjs";
|
|
6
|
+
import json from "@rollup/plugin-json";
|
|
7
|
+
|
|
8
|
+
const name = "maptiler-client"
|
|
9
|
+
|
|
10
|
+
const bundles = [
|
|
11
|
+
// ES module, not minified + sourcemap
|
|
12
|
+
{
|
|
13
|
+
plugins: [
|
|
14
|
+
json(),
|
|
15
|
+
esbuild(),
|
|
16
|
+
],
|
|
17
|
+
output: [
|
|
18
|
+
{
|
|
19
|
+
file: `dist/${name}.mjs`,
|
|
20
|
+
format: "es",
|
|
21
|
+
sourcemap: true
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
input: "src/index.ts",
|
|
25
|
+
watch: {
|
|
26
|
+
include: "src/**"
|
|
27
|
+
},
|
|
28
|
+
external: []
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
// CJS module, not minified + sourcemap
|
|
32
|
+
{
|
|
33
|
+
plugins: [
|
|
34
|
+
nodeResolve(),
|
|
35
|
+
commonjs({ include: "node_modules/**" }),
|
|
36
|
+
globals(),
|
|
37
|
+
json(),
|
|
38
|
+
esbuild()
|
|
39
|
+
],
|
|
40
|
+
output: [
|
|
41
|
+
{
|
|
42
|
+
file: `dist/${name}.cjs`,
|
|
43
|
+
format: "cjs",
|
|
44
|
+
sourcemap: true
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
input: "src/index.ts",
|
|
48
|
+
watch: {
|
|
49
|
+
include: "src/**"
|
|
50
|
+
},
|
|
51
|
+
external: []
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
// UMD module, not minified
|
|
55
|
+
{
|
|
56
|
+
plugins: [
|
|
57
|
+
nodeResolve(), // for the standalone UMD, we want to resolve so that the bundle contains all the dep.
|
|
58
|
+
commonjs({ include: "node_modules/**" }),
|
|
59
|
+
globals(),
|
|
60
|
+
json(),
|
|
61
|
+
esbuild()
|
|
62
|
+
],
|
|
63
|
+
output: [
|
|
64
|
+
{
|
|
65
|
+
name: "maptilerclient",
|
|
66
|
+
file: `dist/${name}.umd.js`,
|
|
67
|
+
format: "umd",
|
|
68
|
+
sourcemap: true
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
input: "src/index.ts",
|
|
72
|
+
watch: {
|
|
73
|
+
include: "src/**"
|
|
74
|
+
},
|
|
75
|
+
external: []
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
// types
|
|
79
|
+
{
|
|
80
|
+
"plugins": [
|
|
81
|
+
dts()
|
|
82
|
+
],
|
|
83
|
+
output: {
|
|
84
|
+
file: `dist/${name}.d.ts`,
|
|
85
|
+
format: "es"
|
|
86
|
+
},
|
|
87
|
+
input: "src/index.ts"
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
|
|
91
|
+
if (process.env.NODE_ENV === "production") {
|
|
92
|
+
bundles.push(
|
|
93
|
+
// ES module, minified
|
|
94
|
+
{
|
|
95
|
+
plugins: [
|
|
96
|
+
json(),
|
|
97
|
+
esbuild({
|
|
98
|
+
sourceMap: false,
|
|
99
|
+
minify: true,
|
|
100
|
+
})
|
|
101
|
+
],
|
|
102
|
+
output: [
|
|
103
|
+
{
|
|
104
|
+
file: `dist/${name}.min.mjs`,
|
|
105
|
+
format: "es",
|
|
106
|
+
}
|
|
107
|
+
],
|
|
108
|
+
input: "src/index.ts",
|
|
109
|
+
external: [],
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
plugins: [
|
|
113
|
+
nodeResolve(), // for the standalone UMD, we want to resolve so that the bundle contains all the dep.
|
|
114
|
+
commonjs({ include: "node_modules/**" }),
|
|
115
|
+
globals(),
|
|
116
|
+
json(),
|
|
117
|
+
esbuild({
|
|
118
|
+
sourceMap: false,
|
|
119
|
+
minify: true,
|
|
120
|
+
})
|
|
121
|
+
],
|
|
122
|
+
output: [
|
|
123
|
+
{
|
|
124
|
+
name: "maptilerclient",
|
|
125
|
+
file: `dist/${name}.umd.min.js`,
|
|
126
|
+
format: "umd",
|
|
127
|
+
sourcemap: false
|
|
128
|
+
}
|
|
129
|
+
],
|
|
130
|
+
input: "src/index.ts",
|
|
131
|
+
watch: {
|
|
132
|
+
include: "src/**"
|
|
133
|
+
},
|
|
134
|
+
external: []
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export default bundles
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
package/src/callFetch.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { config } from "./config";
|
|
2
|
+
|
|
3
|
+
export async function callFetch(resource, options = {}) {
|
|
4
|
+
if (config.fetch === null) {
|
|
5
|
+
throw new Error(
|
|
6
|
+
"The fetch function was not found. If on NodeJS < 18 please specify the fetch function with config.fetch"
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// Control if URL contains the api key
|
|
11
|
+
if (new URL(resource).searchParams.get("key").trim() === "") {
|
|
12
|
+
throw new Error(
|
|
13
|
+
"The MapTiler Cloud API key is missing. Set it in `config.apiKey` or get one for free at https://maptiler.com"
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return config.fetch(resource, options);
|
|
18
|
+
}
|