Tag: mapbox gl js

mapbox gl js – 未捕获TypeError:无法读取null的属性'classList'

我正在用MapBox GL JS创build一个地图。 我在我的index.html页面创build了一个地图,工作正常,但现在我试图在另一个页面上创build另一个地图,当引用地图应该去的div时,我得到一个错误: Uncaught TypeError:无法读取null的属性'classList'。 我不知道为什么会发生这种情况,因为我在我的html中创build了元素,而且我的javascript与在index.html页面(但在不同div上)成功创build第一个映射的javascript完全相同。 我在Node.js中做这件事,并与webpack绑定到一个main.min.js文件,我在index.html和第二个html页面上引用。 "use strict" //here is the MapBox GL JS code at the point the error references in the console //_setupContainer: function() { // var container = this._container; // container.classList.add('mapboxgl-map'); // here is my mapbox new map creation const ACCESSTOKEN = < my access token >; mapboxgl.accessToken = ACCESSTOKEN; […]

为MapboxGL客户端自行托pipe的vector切片呈现不正确

我正在尝试在Node.js中设置一个Web服务器,该服务器使用MapboxGL JS提供要在浏览器中显示的vector图块。 vector图块的数据存储在PostGIS数据库中。 我目前的设置似乎正确的方向,因为我可以看到vector瓷砖被加载和显示在浏览器中。 然而,渲染的结果是不正确的(这是我的地图的一个截图): 绿色build筑脚印的上半部分重复在图像的下半部分。 我还注意到,在放大和缩小时,build筑物会发生“变化”的位置,这表明某种程度上,这些贴图会被渲染为偏移量或不正确的程度。导入的数据位于SRID 4326中。 这是我的代码: var zlib = require('zlib'); var express = require('express'); var mapnik = require('mapnik'); var Promise = require('promise'); var SphericalMercator = require('sphericalmercator'); var mercator = new SphericalMercator({ size: 256 //tile size }); mapnik.register_default_input_plugins(); var app = express(); app.get('/vector-tiles/:layerName/:z/:x/:y.pbf', function(req, res) { var options = { x: parseInt(req.params.x), y: […]