Giter Site home page Giter Site logo

htoooth / leaflet.chinesetmsproviders Goto Github PK

View Code? Open in Web Editor NEW
947.0 38.0 299.0 139 KB

Provider for Chinese Tms Service

Home Page: https://htoooth.github.io/Leaflet.ChineseTmsProviders/

License: MIT License

JavaScript 100.00%
tile-provider epsg leaflet javascript tilelayer

leaflet.chinesetmsproviders's Introduction

Leaflet.ChineseTmsProviders

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

Usage

npm i leaflet.chinatmsproviders

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
});

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

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

./examples/indexBaidu.html

./examples/indexTencent.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 (exclude Annotion)
    • Google.Satellite.Map (include Annotion)
  • Geoq
    • Geoq.Normal.Map
    • Geoq.Normal.PurplishBlue
    • Geoq.Normal.Gray
    • Geoq.Normal.Warm
    • Geoq.Normal.Hydro
  • OSM
    • OSM.Normal.Map
  • Baidu
    • Baidu.Normal.Map
    • Baidu.Satellite.Map (exclude Annotion)
    • Baidu.Satellite.Annotion
  • Tencent
    • Tencent.Normal.Map
    • Tencent.Satellite.Map
    • Tencent.Terrain.Map

Options

key

If you're using TianDiTu, please apply the key and config it in the option, like this:

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

I added a key to the source code, but this key should only be used for testing.

Please note

If you want to use Baidu provider,please install Proj4Leaflet in your project.

About

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

leaflet.chinesetmsproviders's People

Contributors

htoooth avatar lisiur avatar syxpzh avatar zjffun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

leaflet.chinesetmsproviders's Issues

会增加百度地图吗?

纯新手好奇为啥没有百度,可能是百度不提供TMS?
另外,似乎天地图官网的在线地图更新得比使用API获取的要新?我公司旁边的一个大楼,天地图官网在线地图里能看到已经建好了,用这个api看到的还是一片空地。。。

请高手做一下高德的搜索

把高德的搜索做进去,太实用了。
我自己没搞成功。期待。
是高德官网的这个:https://lbs.amap.com/api/javascript-api/example/poi-search/search-after-enter-prompt

`<!doctype html>

<title>输入提示后查询</title> <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.11&key=您申请的key值&plugin=AMap.Autocomplete,AMap.PlaceSearch"></script> <script type="text/javascript" src="https://cache.amap.com/lbs/static/addToolbar.js"></script>
请输入关键字:
<script type="text/javascript"> //地图加载 var map = new AMap.Map("container", { resizeEnable: true }); //输入提示 var autoOptions = { input: "tipinput" }; var auto = new AMap.Autocomplete(autoOptions); var placeSearch = new AMap.PlaceSearch({ map: map }); //构造地点查询类 AMap.event.addListener(auto, "select", select);//注册监听,当选中某条记录时会触发 function select(e) { placeSearch.setCity(e.poi.adcode); placeSearch.search(e.poi.name); //关键字查询查询 } </script> `

Should violate the ToS of Google Maps

According to the FAQ and the ToS of Google Maps, it should violate the ToS of Google Maps to direct access the tiles.

But I also notice that mafengwo uses it by the undocumented way (even tho they leave their API key in the source code). It's really confusing...

Error in Default Funtion call

L.tileLayer.chinaProvider('TianDiTu.Normal.Map').addTo(map); is throwing an error because options is empty, this works:

L.tileLayer.chinaProvider('TianDiTu.Normal.Map',{}).addTo(map);

天地图更新后需要申请key才能使用,我修改了一下源码

    在后面增加&tk=你申请的key即可使用天地图服务
Normal: {
            Map:'http://t{s}.tianditu.gov.cn/vec_w/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=vec&tileMatrixSet=w&TileMatrix={z}&TileRow={y}&TileCol={x}&style=default&tk=你的key',
            Annotion: "http://t{s}.tianditu.gov.cn/cva_w/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=cva&tileMatrixSet=w&TileMatrix={z}&TileRow={y}&TileCol={x}&style=default&tk=你的key"
        },
        Satellite: {
            Map: "http://t{s}.tianditu.gov.cn/img_w/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=img&tileMatrixSet=w&TileMatrix={z}&TileRow={y}&TileCol={x}&style=default&tk=你的key",
            Annotion: "http://t{s}.tianditu.gov.cn/cia_w/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=cia&tileMatrixSet=w&TileMatrix={z}&TileRow={y}&TileCol={x}&style=default&tk=你的key"
        },
        Terrain: {
            Map: "http://t{s}.tianditu.gov.cn/ter_w/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=ter&tileMatrixSet=w&TileMatrix={z}&TileRow={y}&TileCol={x}&style=default&tk=你的key",
            Annotion: "http://t{s}.tianditu.gov.cn/cta_w/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=cta&tileMatrixSet=w&TileMatrix={z}&TileRow={y}&TileCol={x}&style=default&tk=你的key"
        },
        Subdomains: ['0', '1', '2', '3', '4', '5', '6', '7']
    },

修改经纬度,无法显示地图问题,求帮助

我第一使用leaflet,例子是能工作的,我尝试修改,用其他城市的经纬度,但是地图就不能显示出来,不知道是哪里不对,请帮我看下:
下面这个,用例子里面的[31.59, 120.29],就可以出来,用 其他国外的,或者国内的经纬度,就无法显示

例如:[116.38,39.93] [-77.04,38.91]

let map = L.map('mapid', {
center: [-77.04,38.91],
zoom: 12
})

    L.tileLayer.chinaProvider('TianDiTu.Normal.Map', {
      maxZoom: 12,
      minZoom: 5,
      key: '我自己申请的key'
    }).addTo(map);

我用了其他的百度,高德也存在这样的问题。

请帮忙看下,非常感谢。

如何与vue2-leaftlet集成使用呢?

如何与vue2-leaftlet集成使用呢?

  1. l-tile-layer如何替换成chinatms?如果有多个图层,如何使用v-for加载?如果还需要layer-group,如何加载?
  2. l-control-layers能否直接识别出加载的tile-layers?
    谢谢。

One row of tiles doesn't display every 16 rows on Tencent Satellite map

  1. Open the page https://htoooth.github.io/Leaflet.ChineseTmsProviders/examples/indexTencent.html
  2. The Tencent Satellite map is shown, leave all the settings as default,
  3. Do not change the default zoom level also,
  4. Hold down the left mouse button and pan the map one page up.

Then you will see one gray row on the map, the tiles on the row does't display correctly, by continue to pan the map up or down, you will see more gray rows, it seems that there have one row of tiles doesn't display every 16 rows.
This issure only occurs on the Tentcent Satellite map.

天地图即将升级

今天访问了天地图官网时有提示说即将升级服务并且升级后会需要密钥。 密钥肯定是各个开发者来获得但是好像有部分服务连接也会变, 具体怎么变我不清楚。

天地图加了key还是不行

你好,我的项目中用到了天地图的地形图层.
本地测试的时候没有问题,但是发布到网上后地图没有加载出来.
我看网上说tk需要写在参数列表里,不能直接加载url里.不知道是不是真的

这是我在本地测试时候的效果(可以看到地形是显示出来的)
本地测试效果图

这是我发布到网上后:
发布效果图

麻烦看一下是否能修复这个问题
如果方便的话,这是我的网页网址,谢谢!
https://zssanguo.com/html/map.html

leaflet in cordvoa

leaflet in cordvoa with button and attribution , but no map display, osm is ok

切换底图,坐标偏差

使用了天地图和高德地图,切换后地图覆盖物位置有偏移,请问这个要怎么处理?

Baidu maps broken on the example?

Maybe it's just for me but the Baidu maps do not work it's grey all around.

Also noted that for the geog map and the gaode map, you can zoom in to higher zoom levels (18) around/in China and you get a lot of detail but when you zoom in elsewhere around the world you tiles stop appearing when you reach a certain zoom level and you just get grey. Is that always the case? Could one get a key from gaode/geog to avoid this?

Any help is greatly appreciated. Thanks

坐标系表述有些错误吧?

文中这样描述:“All maps use Coordinate Reference Systems (CRS), which are EPSG:4326. ”,但我看加的地图都是EPSG:3857坐标系的。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.