相关疑难解决方法(0)

样式没有加载:Mapbox GL JS

我的目标是创建一个前后地图,在地图上显示一系列坐标标记.

执行代码时,我在控制台中看到此错误消息: Style is not done loading

最终目标是看到一个光标,允许用户水平滑动并查看地图的变化(从之前到之后).

到目前为止,这是我的代码,任何帮助都会有很长的路要走!

$(document).ready(function() {
    var request_one = $.ajax({
        url: "https://geohack-framework-gbhojraj.c9users.io/ny",
        dataType: 'json'
    })
    var request_two = $.ajax({
        url: "https://geohack-framework-gbhojraj.c9users.io/man",
        dataType: 'json'
    });
    $.when(request_one, request_two).done(function(response_one, response_two) {
        console.log(response_one, response_two);
        //create map of ny state
        var nyGeo = response_one[0];
        var manGeo = response_two[0];
        (function() {
            mapboxgl.accessToken = 'pk.eyJ1IjoiamdhcmNlcyIsImEiOiJjaXY4amM0ZHQwMDlqMnlzOWk2MnVocjNzIn0.Pos1M9ZQgxMGnQ_H-bV7dA';
            //manhattan map
            var manCenter = manGeo.features[0].geometry.coordinates[0][0][0];
            console.log('man center is', manCenter);
            var beforeMap = new mapboxgl.Map({
                container: 'before',
                style: 'mapbox://styles/mapbox/light-v9',
                center: manCenter,
                zoom: 5
            });
            console.log('man geo is …
Run Code Online (Sandbox Code Playgroud)

mapbox-gl-js

10
推荐指数
1
解决办法
5407
查看次数

标签 统计

mapbox-gl-js ×1