index.js (1475B)
1 import L from "leaflet"; 2 3 L.Layer.GoogleBase = L.TileLayer.extend({ 4 options: { 5 subdomains: '0123' 6 }, 7 8 getTileUrl: function(coords) { 9 const data = { 10 x: coords.x, 11 y: coords.y, 12 z: 17 - this._getZoomForUrl(), 13 s: this._getSubdomain(coords), 14 lang: navigator.language || '' 15 }; 16 return L.Util.template(this._url, data); 17 } 18 }); 19 20 L.Layer.GoogleMap = L.Layer.GoogleBase.extend({ 21 initialize: function(options) { 22 L.Layer.GoogleBase.prototype.initialize.call( 23 this, 'https://mt{s}.google.com/vt/lyrs=m@169000000&hl={lang}&x={x}&y={y}&zoom={z}', options); 24 } 25 }); 26 27 L.Layer.GoogleTerrain = L.Layer.GoogleBase.extend({ 28 initialize: function(options) { 29 L.Layer.GoogleBase.prototype.initialize.call( 30 this, 'https://mt{s}.google.com/vt/lyrs=t@130,r@206000000&hl={lang}&x={x}&y={y}&zoom={z}', options); 31 } 32 }); 33 34 L.Layer.GoogleHybrid = L.Layer.GoogleBase.extend({ 35 initialize: function(options) { 36 L.Layer.GoogleBase.prototype.initialize.call( 37 this, 'https://mt{s}.google.com/vt/lyrs=h@169000000&hl={lang}&x={x}&y={y}&zoom={z}', options); 38 } 39 }); 40 41 L.Layer.GoogleSat = L.TileLayer.extend({ 42 options: { 43 subdomains: '0123' 44 }, 45 46 initialize: function(options) { 47 L.TileLayer.prototype.initialize.call( 48 this, 'https://mt{s}.google.com/vt/lyrs=s&x={x}&y={y}&z={z}', options); 49 } 50 });