You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
7.0 KiB
23 lines
7.0 KiB
2 years ago
|
|
||
|
/*
|
||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||
|
* or more contributor license agreements. See the NOTICE file
|
||
|
* distributed with this work for additional information
|
||
|
* regarding copyright ownership. The ASF licenses this file
|
||
|
* to you under the Apache License, Version 2.0 (the
|
||
|
* "License"); you may not use this file except in compliance
|
||
|
* with the License. You may obtain a copy of the License at
|
||
|
*
|
||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||
|
*
|
||
|
* Unless required by applicable law or agreed to in writing,
|
||
|
* software distributed under the License is distributed on an
|
||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||
|
* KIND, either express or implied. See the License for the
|
||
|
* specific language governing permissions and limitations
|
||
|
* under the License.
|
||
|
*/
|
||
|
|
||
|
|
||
|
!function (t, e) { "object" == typeof exports && "undefined" != typeof module ? e(exports, require("echarts")) : "function" == typeof define && define.amd ? define(["exports", "echarts"], e) : e(t.bmap = {}, t.echarts) }(this, function (t, o) { "use strict"; function l(t, e) { this._bmap = t, this.dimensions = ["lng", "lat"], this._mapOffset = [0, 0], this._api = e, this._projection = new BMap.MercatorProjection } function n(i, a) { return a = a || [0, 0], o.util.map([0, 1], function (t) { var e = a[t], o = i[t] / 2, n = [], r = []; return n[t] = e - o, r[t] = e + o, n[1 - t] = r[1 - t] = a[1 - t], Math.abs(this.dataToPoint(n)[t] - this.dataToPoint(r)[t]) }, this) } var d; l.prototype.dimensions = ["lng", "lat"], l.prototype.setZoom = function (t) { this._zoom = t }, l.prototype.setCenter = function (t) { this._center = this._projection.lngLatToPoint(new BMap.Point(t[0], t[1])) }, l.prototype.setMapOffset = function (t) { this._mapOffset = t }, l.prototype.getBMap = function () { return this._bmap }, l.prototype.dataToPoint = function (t) { var e = new BMap.Point(t[0], t[1]), o = this._bmap.pointToOverlayPixel(e), n = this._mapOffset; return [o.x - n[0], o.y - n[1]] }, l.prototype.pointToData = function (t) { var e = this._mapOffset; return [(t = this._bmap.overlayPixelToPoint({ x: t[0] + e[0], y: t[1] + e[1] })).lng, t.lat] }, l.prototype.getViewRect = function () { var t = this._api; return new o.graphic.BoundingRect(0, 0, t.getWidth(), t.getHeight()) }, l.prototype.getRoamTransform = function () { return o.matrix.create() }, l.prototype.prepareCustoms = function (t) { var e = this.getViewRect(); return { coordSys: { type: "bmap", x: e.x, y: e.y, width: e.width, height: e.height }, api: { coord: o.util.bind(this.dataToPoint, this), size: o.util.bind(n, this) } } }, l.dimensions = l.prototype.dimensions, l.create = function (t, c) { var m, f = c.getDom(); t.eachComponent("bmap", function (t) { var e = c.getZr().painter, o = e.getViewportRoot(); if ("undefined" == typeof BMap) throw new Error("BMap api is not loaded"); if (d = d || function () { function t(t) { this._root = t } return (t.prototype = new BMap.Overlay).initialize = function (t) { return t.getPanes().labelPane.appendChild(this._root), this._root }, t.prototype.draw = function () { }, t }(), m) throw new Error("Only one bmap component can exist"); if (!t.__bmap) { var n = f.querySelector(".ec-extension-bmap"); n && (o.style.left = "0px", o.style.top = "0px", f.removeChild(n)), (n = document.createElement("div")).style.cssText = "width:100%;height:100%", n.classList.add("ec-extension-bmap"), f.appendChild(n); var r = t.__bmap = new BMap.Map(n), i = new d(o); r.addOverlay(i), e.getViewportRootOffset = function () { return { offsetLeft: 0, offsetTop: 0 } } } r = t.__bmap; var a = t.get("center"), p = t.get("zoom"); if (a && p) { var s = new BMap.Point(a[0], a[1]); r.centerAndZoom(s, p) } (m = new l(r, c)).setMapOffset(t.__mapOffset || [0, 0]), m.setZoom(p), m.setCenter(a), t.coordinateSystem = m }), t.eachSeries(function (t) { "bmap" === t.get("coordinateSystem") && (t.coordinateSystem = m) }) }, o.extendComponentModel({ type: "bmap", getBMap: function () { return this.__bmap }, setCenterAndZoom: function (t, e) { this.option.center = t, this.option.zoom = e }, centerOrZoomChanged: function (t, e) { var o = this.option; return !(function (t, e) { return t && e && t[0] === e[0] && t[1] === e[1] }(t, o.center) && e === o.zoom) }, defaultOption: { center: [104.114129, 37.550339], zoom: 5, mapStyle: {}, mapStyleV2: {}, roam: !1 } }); var p = { "[object Function]": 1, "[object RegExp]": 1, "[object Date]": 1, "[object Error]": 1, "[object CanvasGradient]": 1, "[object CanvasPattern]": 1, "[object Image]": 1, "[object Canvas]": 1 }, s = { "[object Int8Array]": 1, "[object Uint8Array]": 1, "[object Uint8ClampedArray]": 1, "[object Int16Array]": 1, "[object Uint16Array]": 1, "[object Int32Array]": 1, "[object Uint32Array]": 1, "[object Float32Array]": 1, "[object Float64Array]": 1 }, c = Object.prototype.toString; function h(t) { if (null == t || "object" != typeof t)
|