leaflet.chinatmsproviders.cors

An extension to Leaflet that contains configurations for various Chinese tile providers.

Usage no npm install needed!

<script type="module">
  import leafletChinatmsprovidersCors from 'https://cdn.skypack.dev/leaflet.chinatmsproviders.cors';
</script>

README

Leaflet.ChineseTmsProviders

An extension to Leaflet that contains configurations for various Chinese tile providers.

Usage

npm i leaflet.chinatmsproviders.cors

Leaflet-ChineseTmsProviders providers are refered to with a provider.<variant>.<type> -string. Let's say you want to add the nice Normal.Map base layers from www.tianditu.com to your map, you pass TianDiTu.Normal.Map to the L.tileLayer.chinaProvider-constructor, which will return a L.TileLayer instance for TianDiTu Normal Map tile layer.

//add TianDiTu Normal Map Layer to map.
L.tileLayer.chinaProvider('TianDiTu.Normal.Map').addTo(map);

Example

var map = L.map('map', {
    center: [31.59, 120.29],
    zoom: 12,
    cors: 'localhost:81'
});

L.tileLayer.chinaProvider('TianDiTu.Normal.Map',{maxZoom:18,minZoom:5}).addTo(map);
L.tileLayer.chinaProvider('TianDiTu.Normal.Annotion',{maxZoom:18,minZoom:5}).addTo(map);

server {
    listen       81;
    server_name  localhost;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location /DataServer {
        add_header Access-Control-Allow-Origin *;
        add_header Access-Control-Allow-Headers X-Requested-With;
        add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
        
        proxy_pass http://t7.tianditu.com;
    }

    location /ArcGIS {
        add_header Access-Control-Allow-Origin *;
        add_header Access-Control-Allow-Headers X-Requested-With;
        add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
        
        proxy_pass http://map.geoq.cn;
    }
}

There are more examples at the examples folder like below.

./examples/indexTianDiTu.html

./examples/indexGaoDe.html

./examples/indexGoogle.html

./examples/indexGeoq.html

./examples/indexOSM.html

Above all maps use Coordinate Reference Systems (CRS), which are EPSG:3857.

Providers

Current options suitable for tile layers are:

  • TianDiTu
    • TianDiTu.Normal.Map
    • TianDiTu.Normal.Annotion
    • TianDiTu.Satellite.Map
    • TianDiTu.Satellite.Annotion
    • TianDiTu.Terrain.Map
    • TianDiTu.Terrain.Annotion
  • GaoDe
    • GaoDe.Normal.Map (include Annotion)
    • GaoDe.Satellite.Map
    • GaoDe.Satellite.Annotion
  • Google
    • Google.Normal.Map (include Annotion)
    • Google.Satellite.Map
  • Geoq
    • Geoq.Normal.Map
    • Geoq.Normal.PurplishBlue
    • Geoq.Normal.Gray
    • Geoq.Normal.Warm
    • Geoq.Normal.Hydro
  • OSM
    • OSM.Normal.Map

About

This work was inspired from https://github.com/tontita/Leaflet.KoreanTmsProviders, and https://github.com/leaflet-extras/leaflet-providers.