找不到我的Mapbox样式地图的Mapbox矢量图块URL [英] Cannot find Mapbox Vector Tile URL for my Mapbox Style map

查看:541
本文介绍了找不到我的Mapbox样式地图的Mapbox矢量图块URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道如何获取Mapbox矢量图块地图的URL(又称样式")吗?我只能得到一个看起来像这样的样式地址:mapbox://styles/myusername/r3411y10ngh4sh3tc3tc,但是我使用的插件需要URL才能将Mapbox的Vector Tiles与Leaflet集成在一起:

Does anyone know how to get the URL for a Mapbox vector tile map (aka a "style")? I can only get a style address that looks like this: mapbox://styles/myusername/r3411y10ngh4sh3tc3tc, but I am using a plugin that requires a URL to integrate Mapbox's Vector Tiles with Leaflet: https://github.com/SpatialServer/Leaflet.MapboxVectorTile/blob/master/docs/configuration.md

我尝试用Mapbox提供的样式地址代替URL

I tried substituting the style address provided by Mapbox for the URL

var config = {
  url: "mapbox://styles/myusername/fwaoij32wlfij23slkfj3",
  ...etc
};

var mvtSource = new L.TileLayer.MVTSource(config);
map.addLayer(mvtSource);

,但出现错误,无法将样式地址作为URL读取.有什么建议?我应该使用其他插件吗?

but I get an error where it can't read the style address as a URL. Any suggestions? Should I be using a different plugin?

更新

简而言之,Mapbox样式的URL尚不可用.这是我从Mapbox收到的回复:

In short, the URL for a Mapbox style is not yet available. Here is a response I received from Mapbox:

传单尚未与Mapbox Studio中制作的样式兼容,因为这些样式需要基于GL的渲染器.我们目前正在开发一个新的API,以允许您将Studio样式与Leaflet一起使用,我们希望它会在几周内启动.

Leaflet is not yet compatible with styles made in Mapbox Studio since these styles require a GL-based renderer. We're currently working on a new API to allow you to use your Studio style with Leaflet, we expect it to launch in a few weeks.

目前,您可以使用Mapbox GL JS加载Mapbox Studio样式.您仍然可以访问栅格地图ID(使用Mapbox Editor,Mapbox Studio Classic创建的地图)以使用Leaflet加载-这些ID位于Studio仪表板的经典"标签下.

At this time, you can use Mapbox GL JS to load your Mapbox Studio style. You can still access raster map IDs (maps made with Mapbox Editor, Mapbox Studio Classic) to load with Leaflet - these are found under the "Classic" tab in the Studio dashboard.

推荐答案

Leaflet.MapboxVectorTile插件使用了与Mapbox GL JS库不同的样式方法.

The Leaflet.MapboxVectorTile plugin uses a different approach to styles than, for example, the Mapbox GL JS library does.

您可以在JSON中下载在Mapbox Studio中创建的样式,但是对于Leaflet.MapboxVectorTile,您必须以编程方式创建它们,就像在

Styles you create in Mapbox Studio can be downloaded as JSON, but for Leaflet.MapboxVectorTile you have to create them programmatically as you can see in the documentation. You can still use their vector tile URL https://b.tiles.mapbox.com/v4/mapbox.mapbox-streets-v6/{z}/{x}/{y}.vector.pbf?access_token=<public api token>, but styles would probably have to be rewritten/done from scratch again.

您可以使用 Mapbox Gl Javascript 使用您创建的样式,但我不知道您当前的项目有多广泛,以及它是否会与其他(Leaflet)插件冲突:

You can use the Mapbox Gl Javascript to create a map with the style you created, but I don't know how extensive your current project is and if it would conflict with other (Leaflet) plugins:

mapboxgl.accessToken = '<public API token>';
var map = new mapboxgl.Map({
    container: 'map',
    style: 'mapbox://styles/<your name>/<style id>',
    center: [-74.50, 40],
    zoom: 9
});

这篇关于找不到我的Mapbox样式地图的Mapbox矢量图块URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆