_waypointsVisible: function() {
			var wps = this.getWaypoints(),
				mapSize,
				bounds,
				boundsSize,
				i,
				p;

			try {
				mapSize = this._map.getSize();

				for (i = 0; i < wps.length; i++) {
					p = this._map.latLngToLayerPoint(wps[i].latLng);

					if (bounds) {
						bounds.extend(p);
					} else {
						bounds = L.bounds([p]);
					}
				}

				boundsSize = bounds.getSize();
				return (boundsSize.x > mapSize.x / 5 ||
					boundsSize.y > mapSize.y / 5) && this._waypointsInViewport();

			} catch (e) {
				return false;
			}
		},
  _getCellNumBounds: function () {
    var worldBounds = this._map.getPixelWorldBounds();
    var size = this._getCellSize();

    return worldBounds ? bounds(
      worldBounds.min.divideBy(size).floor(),
      worldBounds.max.divideBy(size).ceil().subtract([1, 1])) : null;
  }
Exemplo n.º 3
0
    render() {
        let { width, height } = getComputedStyle(this.dom);
        let map = null;
        // 百度地图
        if(this.mapType == 'baidu') {
            let crs = new L.Proj.CRS('EPSG:3395',
                '+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs',
                {
                    resolutions: function () {
                        let level = 19
                        let res = [];
                        res[0] = Math.pow(2, 18);

                        for(let i = 1; i < level; i++) {
                            res[i] = Math.pow(2, (18 - i));
                        }

                        return res;
                    }(),
                    origin: [0, 0],
                    bounds: L.bounds([0, 20037508.342789244], [20037508.342789244, 0])
                });


            map = L.map(this.dom, {
                renderer: 'canvas',
                minZoom: 2,
                crs: crs
            }).setView([39.91349, 116.407945], 3);

            L.tileLayer(this.tileLayer, {
                attribution: '&copy; 百度地图',
                maxZoom: 18,
                minZoom: 3,
                subdomains: '1234',
                tms: true
            }).addTo(map);
        }
        else {
            map = L.map(this.dom, {
                renderer: 'canvas',
                minZoom: 2,
            }).setView([39.91349, 116.407945], 3);

            L.tileLayer(this.tileLayer, {
                maxZoom: 18,
                minZoom: 3,
            }).addTo(map);
        }

        map.invalidateSize(true);

        return map;
    }
Exemplo n.º 4
0
  _calculateBbox: function () {
    var pixelBounds = this._map.getPixelBounds();

    var sw = this._map.unproject(pixelBounds.getBottomLeft());
    var ne = this._map.unproject(pixelBounds.getTopRight());

    var neProjected = this._map.options.crs.project(ne);
    var swProjected = this._map.options.crs.project(sw);

    // this ensures ne/sw are switched in polar maps where north/top bottom/south is inverted
    var boundsProjected = bounds(neProjected, swProjected);

    return [boundsProjected.getBottomLeft().x, boundsProjected.getBottomLeft().y, boundsProjected.getTopRight().x, boundsProjected.getTopRight().y].join(',');
  },
  _update: function () {
    if (!this._map) {
      return;
    }

    var mapBounds = this._map.getPixelBounds();
    var cellSize = this._getCellSize();

    // cell coordinates range for the current view
    var cellBounds = bounds(
      mapBounds.min.divideBy(cellSize).floor(),
      mapBounds.max.divideBy(cellSize).floor());

    this._removeOtherCells(cellBounds);
    this._addCells(cellBounds);

    this.fire('cellsupdated');
  },