Skip to content

Commit 631a6be

Browse files
authored
CU-529 update readme new template (#82)
* CU-529 update readme new template * CU-529 add demo iamge
1 parent 7dd6f0d commit 631a6be

File tree

1 file changed

+147
-61
lines changed

1 file changed

+147
-61
lines changed

readme.md

Lines changed: 147 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,7 @@
1-
<p align="center">
2-
<a href="https://docs.maptiler.com/client-js/">official page →</a><br>
3-
<img src="images/maptiler-client-logo.svg" width="400px">
4-
</p>
5-
6-
<p align="center" style="color: #AAA">
7-
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!
8-
</p>
9-
10-
<p align="center">
11-
<img src="images/JS-logo.svg" width="20px">
12-
<img src="images/TS-logo.svg" width="20px">
13-
<img src="https://img.shields.io/npm/v/@maptiler/client"></img>
14-
<img src="https://img.shields.io/twitter/follow/maptiler?style=social"></img>
15-
</p>
1+
<img src="./images/maptiler-client-logo.svg" alt="Company Logo" height="32"/>
162

173
# API Client Library for JavaScript / TypeScript
184

19-
## What?
20-
215
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:
226
- [Geocoding forward and reverse](#-geocoding)
237
- [Geolocation from visitor's IP address](#%EF%B8%8F%EF%B8%8F-geolocation)
@@ -26,8 +10,6 @@ The **MapTiler Client JS** exposes a number of handy functions that wrap API cal
2610
- [Static maps of all sorts](#%EF%B8%8F-static-maps)
2711
- [Elevation lookup with batch features](#-elevation)
2812

29-
## Why?
30-
3113
The project is entirely written in TypeScript and all the function arguments are nicely documented and typed.
3214

3315
- Better developer experience of working with APIs in the code editor - with parameter info, quick info, and member lists.
@@ -38,15 +20,63 @@ The project is entirely written in TypeScript and all the function arguments are
3820
- Runs: in Node.js or in browser
3921
- Open source license
4022

41-
# Install
23+
[![](https://img.shields.io/npm/v/@maptiler/client?style=for-the-badge&labelColor=D3DBEC&color=f2f6ff&logo=npm&logoColor=333359)](https://www.npmjs.com/package/@maptiler/client) ![](https://img.shields.io/badge/-white?style=for-the-badge&logo=javascript)![](https://img.shields.io/badge/-white?style=for-the-badge&logo=typescript)
24+
---
25+
26+
📖 [Documentation](https://docs.maptiler.com/client-js/) &nbsp; 📦 [NPM Package](https://www.npmjs.com/package/@maptiler/client) &nbsp; 🌐 [Website](https://docs.maptiler.com/client-js/) &nbsp; 🔑 [Get API Key](https://cloud.maptiler.com/account/keys/)
27+
28+
---
29+
30+
<br>
31+
32+
<details> <summary><b>Table of Contents</b></summary>
33+
<ul>
34+
<li><a href="#-installation">Installation</a></li>
35+
<li><a href="#-basic-usage">Basic Usage</a></li>
36+
<li><a href="#-related-examples">Examples</a></li>
37+
<li><a href="#-api-reference">API Reference</a></li>
38+
<li><a href="#-support">Support</a></li>
39+
<li><a href="#-contributing">Contributing</a></li>
40+
<li><a href="#-license">License</a></li>
41+
</ul>
42+
</details>
43+
44+
<p align="center"> <img src="https://docs.maptiler.com/client-js/description/img/code.gif" alt="Demo Screenshot" width="80%"/> <br />
45+
</p>
46+
<br>
47+
48+
## 📦 Installation
49+
50+
### ES module from NPM
51+
4252
```shell
4353
npm install --save @maptiler/client
4454
```
4555

46-
# API documentation
47-
In addition to the details and examples provided in this readme, check out the [complete API documentation](https://docs.maptiler.com/client-js/).
56+
### From NodeJS
57+
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.
58+
59+
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*.
60+
61+
```js
62+
import {
63+
config,
64+
// ...
65+
} from '@maptiler/client';
66+
67+
// For this example to work, you must bring your own node-compatible fetch,
68+
// unles you are using a version of Nodejs that already contains fetch (>=18)
69+
import fetch from 'node-fetch';
70+
71+
config.fetch = fetch;
72+
73+
// ...
74+
```
75+
76+
<br>
77+
78+
## 🚀 Basic Usage
4879

49-
# Quick start
5080
```ts
5181
// Import the whole library
5282
import * as maptilerClient from '@maptiler/client';
@@ -64,15 +94,30 @@ import {
6494
} from '@maptiler/client';
6595
```
6696

97+
<br>
98+
99+
## 💡 Related Examples
100+
67101
The [examples](examples/) folder includes are featuring usages for **NodeJS**, **browser with UMD** and **browser with ES module**.
68102

69-
# Easy access to MapTiler Cloud API
103+
<br>
104+
105+
## 📘 API Reference
106+
107+
For detailed guides, API reference, and advanced examples, visit our comprehensive documentation:
108+
109+
[API documentation](https://docs.maptiler.com/client-js/)
110+
111+
### Easy access to MapTiler API
112+
70113
Here is the list of service wrapper functions that are built-in:
71114

72-
## 🔍 Geocoding
115+
### 🔍 Geocoding
116+
73117
> ✅ Please, use geocoding functions only from client-side (browser) and do not 🚫 **store** or **redistribute** MapTiler Cloud API data. In case of doubt, consult the [terms](https://www.maptiler.com/cloud/terms/#explicitly-prohibited-use) ⚖️
74118
75-
### Forward
119+
#### Forward
120+
76121
You want to know the longitude and latitude of a specific place, use the forward geocoding:
77122
```ts
78123
// in an async function, or as a 'thenable':
@@ -85,7 +130,8 @@ You can provide some options such as:
85130

86131
Read more about forward geocoding as well as feature ID query and batch forward geocoding on our [official documentation](https://docs.maptiler.com/client-js/geocoding/#forward).
87132

88-
### Reverse
133+
#### Reverse
134+
89135
You wan to tknow the name of a place, given a longitude-latitude? Use the reverse geocoding:
90136
```ts
91137
// in an async function, or as a 'thenable':
@@ -95,7 +141,8 @@ The same option object as the forward geocoding can be provided.
95141

96142
Read more about reverse geocoding on our [official documentation](https://docs.maptiler.com/client-js/geocoding/#reverse).
97143

98-
### Language
144+
#### Language
145+
99146
For both *forward* and *reverse* geocoding, this library provides a list of supported languages as shorthands that include [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:
100147

101148
```ts
@@ -106,7 +153,8 @@ The special language `AUTO` will detect the platform/browser preferred language.
106153

107154
If the language is not specified as options, MapTiler Cloud will use the `Accept-language` from the HTTP header of the request. The language seleted this way is generaly similar to the `Language.AUTO` mode, but can still differ in some cases ([read more](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language)).
108155

109-
## 🕵️‍♂️ Geolocation
156+
### 🕵️‍♂️ Geolocation
157+
110158
The geolocation service provides location informations of a visitor using its IP address.
111159

112160
The geolocation uses the IP address of a visitors to provide informations about their location, such as city, region, country, timezone, etc. The precision is lower than GPS but does not require visitors to explicitely enable the location service from their web browser.
@@ -119,10 +167,12 @@ const result = await maptilerClient.geolocation.info();
119167

120168
Read more about geolocation on our [official documentation](https://docs.maptiler.com/client-js/geolocation/).
121169

122-
## 🌐 Coordinates
170+
### 🌐 Coordinates
171+
123172
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!
124173

125-
### Search
174+
#### Search
175+
126176
The `search` lets you perform a query in a free form fashion. Here are some examples:
127177
```ts
128178
// in an async function, or as a 'thenable':
@@ -136,7 +186,8 @@ The `transformations` options retrieves a lot more details about the CRS that Ma
136186

137187
Read more about searching coordinate systems on our [official documentation](https://docs.maptiler.com/client-js/coordinates/#search).
138188

139-
### Transform
189+
#### Transform
190+
140191
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).
141192

142193
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:
@@ -153,7 +204,8 @@ const resultB = await maptilerClient.coordinates.transform([[10, 48], [1, 45]],
153204

154205
Read more about transforming coordinates on our [official documentation](https://docs.maptiler.com/client-js/coordinates/#transform).
155206

156-
## 💽 Data
207+
### 💽 Data
208+
157209
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:
158210

159211
```ts
@@ -165,7 +217,8 @@ Since the result is a GeoJSON, it can easily be added to a `map` with `.addSourc
165217

166218
Read more about fetching your own data on our [official documentation](https://docs.maptiler.com/client-js/data/).
167219

168-
## 🗺️ Static maps
220+
### 🗺️ Static maps
221+
169222
> ✅ Please, use static maps URLs only from client side `<img>` elements, and do not 🚫 store or redistribute the static map files. In case of doubt, consult the [terms](https://www.maptiler.com/cloud/terms/#explicitly-prohibited-use) ⚖️
170223
171224
Maptiler Cloud provides many possibilities for creating static maps as PNG, JPEG or WebP images. They all offer the possibilities to:
@@ -178,8 +231,8 @@ Three modes are available: `centered`, `bounded` and `automatic`.
178231
> 📣 *__important:__* <span style="text-decoration: underline">only image **URLs** are returned.</span>
179232
> Contrary to the other functions of this library, the static map functions **do not** perform any query to MapTiler Cloud API, instead they build the image URL for you to use in `<img>` elements.
180233
234+
#### Map Styles
181235

182-
### Map Styles
183236
In the following static map functions, the `option` object features a `style` property that can be a string or one of the built-in style shorthand. Here is the full list:
184237

185238
- `MapStyle.STREETS`, reference style for navigation and city exploration
@@ -218,7 +271,8 @@ In the following static map functions, the `option` object features a `style` pr
218271
- `MapStyle.OPENSTREETMAP` (reference style, this one does not have any variants)
219272
- `MapStyle.OCEAN` (reference style, this one does not have any variants)
220273

221-
### Centered static maps
274+
#### Centered static maps
275+
222276
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).
223277
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).
224278

@@ -246,8 +300,8 @@ const imageLink = maptilerClient.staticMaps.centered(
246300

247301
Read more about centered static maps on our official [API documentation](https://docs.maptiler.com/cloud/api/static-maps/#center-based-image).
248302

303+
#### Bounded static maps
249304

250-
### Bounded static maps
251305
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.
252306

253307
```ts
@@ -289,7 +343,8 @@ As you may notice, the geo bounding box could have very different proportions th
289343

290344
Read more about bounded static maps on our official [API documentation](https://docs.maptiler.com/cloud/api/static-maps/#bounds-based-image).
291345

292-
### Automatic static maps
346+
#### Automatic static maps
347+
293348
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.
294349

295350
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 available as a GeoJSON:
@@ -332,7 +387,8 @@ And voila!
332387
333388
Read more about bounded static maps on our official [API documentation](https://docs.maptiler.com/cloud/api/static-maps/#auto-fitted-image).
334389

335-
## 🏔️ Elevation
390+
### 🏔️ Elevation
391+
336392
With the elevation API, it's possible to get the elevation in metter from any location. It's possible lookup and compute elevation for a single location, to provide a batch of points, from a GeoJSON LineString or from a GeoJSON MultiLineString!
337393

338394
> ℹ️ Under the hood, the elevation API is fueled by MapTiler Cloud's **RGB Terrain** raster tileset, which is a composite of many high-resolution DEMs from all over the world, currated and processed by our geodata team! The same dataset is also fueling our SDK's elevation (3D terrain) and the hillshading we use in many of our styles.
@@ -341,7 +397,8 @@ With the elevation API, it's possible to get the elevation in metter from any lo
341397
342398
Let's see how to use it:
343399

344-
### At a single location
400+
#### At a single location
401+
345402
```ts
346403
// Not mandatory, but it's to explain where the type comes from:
347404
import { Position } from "geojson";
@@ -353,7 +410,8 @@ The returned value is also a *GeoJSON* `Position` array, but with three elements
353410

354411
Read more about elevation lookup for a single location in our [official documentation](https://docs.maptiler.com/client-js/elevation/#at).
355412

356-
### Batch mode
413+
#### Batch mode
414+
357415
```ts
358416
// Not mandatory, but it's to explain where the type comes from:
359417
import { Position } from "geojson";
@@ -375,7 +433,8 @@ const elevatedPeaks = await maptilerClient.elevation.batch(peaks);
375433

376434
Read more about elevation lookup for a batch of locations in our [official documentation](https://docs.maptiler.com/client-js/elevation/#batch).
377435

378-
### From a GeoJSON LineString
436+
#### From a GeoJSON LineString
437+
379438
In the *GeoJSON* LineString case, it clones the entire structure and the positions arrays of the clone will contain three element: `[lng, lat, elevation]`. The original LineString is not mutated nor pointed at.
380439

381440
```ts
@@ -394,7 +453,8 @@ const someElevatedLineString = await maptilerClient.elevation.fromLineString(som
394453

395454
Read more about elevation lookup for a `LineString` in our [official documentation](https://docs.maptiler.com/client-js/elevation/#linestring).
396455

397-
### From a GeoJSON MultiLineString
456+
#### From a GeoJSON MultiLineString
457+
398458
In the *GeoJSON* MultiLineString case, it clones the entire structure and the positions arrays of the clone will contain three element: `[lng, lat, elevation]`. The original MultiLineString is not mutated nor pointed at.
399459

400460
```ts
@@ -417,10 +477,12 @@ const someElevatedMultiLineString = await maptilerClient.elevation.fromMultiLine
417477

418478
Read more about elevation lookup for a `MultiLineString` in our [official documentation](https://docs.maptiler.com/client-js/elevation/#multilinestring).
419479

420-
### Caching
480+
#### Caching
481+
421482
In order to increase performance while reducing unnecessary elevation data fetching, the elevation tiles are cached. This is particularly important for the LineString and MultiLineString lookups because GeoJSON data are likely to come from a recorded or planned route, where position points are very close to one another.
422483

423-
## 🧮 Math
484+
### 🧮 Math
485+
424486
Some operations can be fairly repetitive: WGS84 to Mercator, WGS84 to *zxy* tile index, distance between two points with Haversine formula, etc. As a result, we have decided to expose a `math` package providing the most recurent feature, so that, just like us at MapTiler, you no longer need to copy-paste the same function from your previous project!
425487

426488
The `math` package differs from the others in the sense that it does not call the MapTiler Cloud API, instead it operates fully on the machine it's running on.
@@ -459,27 +521,51 @@ const tileXY = maptilerClient.math.wgs84ToTileIndex(montBlancPeakWgs84, 14);
459521
// and many more!
460522
```
461523

462-
Please find out more about the math package in our [official documentation](https://docs.maptiler.com/client-js/math):
524+
Please find out more about the math package in our [official documentation](https://docs.maptiler.com/client-js/math).
463525

464-
# From NodeJS
465-
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.
526+
<br>
466527

467-
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*.
528+
## 💬 Support
468529

469-
```js
470-
import {
471-
config,
472-
// ...
473-
} from '@maptiler/client';
530+
- 📚 [Documentation](https://docs.maptiler.com/client-js/) - Comprehensive guides and API reference
531+
- ✉️ [Contact us](https://maptiler.com/contact) - Get in touch or submit a request
532+
- 🐦 [Twitter/X](https://twitter.com/maptiler) - Follow us for updates
474533

475-
// For this example to work, you must bring your own node-compatible fetch,
476-
// unles you are using a version of Nodejs that already contains fetch (>=18)
477-
import fetch from 'node-fetch';
534+
<br>
478535

479-
config.fetch = fetch;
536+
---
480537

481-
// ...
482-
```
538+
<br>
539+
540+
## 🤝 Contributing
541+
542+
We love contributions from the community! Whether it's bug reports, feature requests, or pull requests, all contributions are welcome:
543+
544+
- Fork the repository and create your branch from `main`
545+
- If you've added code, add tests that cover your changes
546+
- Ensure your code follows our style guidelines
547+
- Give your pull request a clear, descriptive summary
548+
- Open a Pull Request with a comprehensive description
549+
550+
<br>
551+
552+
## 📄 License
553+
554+
This project is licensed under the BSD 3-Clause License – see the [LICENSE](./LICENSE) file for details.
555+
556+
### Terms and usage limitations
483557

484-
# Terms and usage limitations
485558
The data fetched from MapTiler Cloud API, with or without this library, cannot be stored or redistributed in any ways. If you have any doubt about your specific usecase, please consult our [legal terms](https://www.maptiler.com/cloud/terms/#explicitly-prohibited-use) or contact us.
559+
560+
<br>
561+
562+
<p align="center" style="margin-top:20px;margin-bottom:20px;"> <a href="https://cloud.maptiler.com/account/keys/" style="display:inline-block;padding:12px 32px;background:#F2F6FF;color:#000;font-weight:bold;border-radius:6px;text-decoration:none;"> Get Your API Key <sup style="background-color:#0000ff;color:#fff;padding:2px 6px;font-size:12px;border-radius:3px;">FREE</sup><br /> <span style="font-size:90%;font-weight:400;">Start building with 100,000 free map loads per month ・ No credit card required.</span> </a> </p>
563+
564+
<br>
565+
566+
<p align="center"> 💜 Made with love by the <a href="https://www.maptiler.com/">MapTiler</a> team <br />
567+
<p align="center">
568+
<a href="https://docs.maptiler.com/client-js/">Website</a> •
569+
<a href="https://docs.maptiler.com/client-js/">Documentation</a> •
570+
<a href="https://github.com/maptiler/maptiler-client-js">GitHub</a>
571+
</p>

0 commit comments

Comments
 (0)