b752bb5e458949b0dd2ba20c3e1664de8756b44f.svn-base 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import { TileLayer } from 'maptalks'
  2. let tiles = [
  3. new TileLayer('base', {
  4. 'offset': [100000, 10000],
  5. 'urlTemplate': function(x, y, z, domain) {
  6. for (var a = "", c = x, d = y, e = 0; e < z; e++) {
  7. a = ((c & 1) + 2 * (d & 1)).toString() + a;
  8. c >>= 1;
  9. d >>= 1
  10. }
  11. return 'http://dynamic.t'+domain+'.tiles.ditu.live.com/comp/ch/' + a + '?it=G,VE,BX,L,LA&mkt=zh-cn,syr&n=z&og=111&ur=CN&cstl=w4c'
  12. },
  13. 'subdomains': ['0', '1', '2', '3']
  14. }),
  15. new TileLayer('base', {
  16. 'urlTemplate': 'https://tileserver.memomaps.de/tilegen/{z}/{x}/{y}.png',
  17. 'subdomains': ['a', 'b', 'c']
  18. }),
  19. new TileLayer('base', {
  20. 'urlTemplate': 'http://{s}.tile.stamen.com/watercolor/{z}/{x}/{y}.png',
  21. 'subdomains': ['a', 'b', 'c']
  22. }),
  23. new TileLayer('base', {
  24. 'urlTemplate': 'http://{s}.tiles.wmflabs.org/hikebike/{z}/{x}/{y}.png',
  25. 'subdomains': ['a', 'b', 'c']
  26. }),
  27. new TileLayer('base', {
  28. 'urlTemplate': 'http://{s}.tile.osm.org/{z}/{x}/{y}.png',
  29. 'subdomains': ['a', 'b', 'c']
  30. }),
  31. new TileLayer('Carto light', {
  32. 'urlTemplate': 'http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png',
  33. 'subdomains': ['a', 'b', 'c', 'd']
  34. }),
  35. new TileLayer('Carto dark', {
  36. 'urlTemplate': 'http://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}.png',
  37. 'subdomains': ['a', 'b', 'c', 'd']
  38. }),
  39. new TileLayer('base', {
  40. spatialReference: {
  41. projection: 'EPSG:3857'
  42. },
  43. urlTemplate: 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
  44. subdomains: ['a', 'b', 'c'],
  45. attribution: '&copy; <a href="http://www.osm.org" target="_blank">OpenStreetMap</a> contributors'
  46. })
  47. ]
  48. let index = localStorage.getItem('theme') || 1
  49. let theme = document.querySelector('#theme')
  50. theme.innerHTML = tiles.map((t, i) => `<option value="${i}">主题${i+1}</option>`).join('')
  51. theme.value = index
  52. theme.addEventListener('change', () => {
  53. localStorage.setItem('theme', theme.value)
  54. location.reload()
  55. })
  56. export default () => {
  57. return tiles[index]
  58. }