向 Mapbox.js 添加自定义地图样式 [英] Add custom map style to Mapbox.js

查看:200
本文介绍了向 Mapbox.js 添加自定义地图样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚使用 Mapbox Studio 创建了我的个人地图样式,并尝试将它与 Mapbox.js 一起使用.(不是 Mapbox Gl js !!)正如文档中所写

I just created my personal map style with Mapbox Studio and i'm try to use it with Mapbox.js. (NOT Mapbox Gl js!!) As written in the docu

您可以使用 Mapbox GL JS 或 Mapbox Mobile SDK 从 API 加载和显示样式,也可以直接从 API 请求样式.此请求需要具有样式的访问令牌:读取范围.

You can load and display styles from the API using Mapbox GL JS or the Mapbox Mobile SDKs or you can request styles directly from the API. This request requires an access token with the styles:read scope.

我添加了我的 <头 > 链接到:https://api.mapbox.com/styles/v1/myusername/mystyleid?access_token=mypublicaccesstoken

I added on my < head > a link to: https://api.mapbox.com/styles/v1/myusername/mystyleid?access_token=mypublicaccesstoken

我可以看到 JSON 响应,但我仍然看到基本的地图样式.

I can see the JSON response but i still see basic map style.

如何在 mapbox.js 中使用我的自定义样式?

How can i use my custom style in mapbox.js?

推荐答案

抱歉,这不起作用.Mapbox 样式用于 Mapbox GL 和原生 iOS 和 Android SDK.您不能将它们与经典的 Mapbox JS 一起使用.Mapbox JS 支持光栅图块,你不能设置它们的样式.它们只是图像.Mapbox GL 和本机 SDK(可以)使用矢量切片,并且这些都是可样式化的.如果您想创建用于 Mapbox JS 的自定义图块集,您可以使用 Mapbox Studio Classic 来实现.

Sorry, but that won't work. Mapbox Styles are for use with Mapbox GL and the native iOS and Android SDK's. You can't use them with classic Mapbox JS. Mapbox JS supports raster tiles, you can't style those. They're just images. Mapbox GL and the native SDK's (can) use vector tiles and those are stylable. If you want to create a custom tileset for use with Mapbox JS you can do so using Mapbox Studio Classic.

这篇关于向 Mapbox.js 添加自定义地图样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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