{"size": 1120, "ext": "js", "max_stars_repo_path": "baidu-tile-layer.js", "max_stars_repo_name": "luobotang/leaflet-baidu-tile-layer", "max_stars_repo_stars_event_min_datetime": "2017-07-14T01:43:07.000Z", "max_stars_repo_stars_event_max_datetime": "2018-10-31T06:02:59.000Z", "max_issues_repo_path": "baidu-tile-layer.js", "max_issues_repo_name": "luobotang/leaflet-baidu-tile-layer", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "baidu-tile-layer.js", "max_forks_repo_name": "luobotang/leaflet-baidu-tile-layer", "max_forks_repo_forks_event_min_datetime": "2017-06-06T08:09:20.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-13T06:29:13.000Z"}
{"max_stars_count": 2, "max_issues_count": null, "max_forks_count": 2, "avg_line_length": 21.1320754717, "max_line_length": 66, "alphanum_fraction": 0.6196428571}
(function (factory) {
	
	if (typeof exports !== 'undefined') {
		module.exports = factory(require('leaflet'))
	} else if (window.L) {
		factory(window.L)
	} else {
		throw new Error('require LeafLet')
	}

})(function (L) {

	var MAX_ZOOM = 18
	var TILE_URL = (
		'http://online1.map.bdimg.com/onlinelabel/' +
		'?qt=tile&x={x}&y={y}&z={z}&styles=pl&udt=20170106&scaler=1&p=0'
	)

	L.CRS.BaiduCRS = L.extend({}, L.CRS.Earth, {

		code: 'BaiduTileCRS',

		projection: L.Projection.SphericalMercator,

		scale: function (zoom) {
			return Math.pow(2, MAX_ZOOM - zoom) // m/px
		},

		transformation: {
			transform: function (point, scale) {
				return this._transform(point.clone, scale)
			},
			_transform: function (point, scale) {
				point.x = point.x / scale
				point.y = -point.y / scale
				return point
			},
			untransform: function (point, scale) {
				return L.point(point.x * scale, -point.y * scale)
			}
		}
	})

	L.BaiduTileLayer = L.TileLayer.extend({
		getTileUrl: function (coords) {
			return L.Util.template(TILE_URL, {
				x: coords.x,
				y: -coords.y,
				z: this._getZoomForUrl()
			})
		}
	})
})