Maki图标并非全部显示 [英] Maki icons not all displaying

查看:84
本文介绍了Maki图标并非全部显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个允许用户为其 geojson 点选择图标的地图.我只想使用默认的地图样式(街道|户外|浅|暗|卫星)和Maki图标,但是,并非所有图标都显示在所有样式上.

例如,在所有地图样式中均显示自行车"和咖啡馆",仅在卫星上显示圆圈",而在其中任何一个上均不显示标记".

在我为其他目的开发的一种样式上,即使我知道我没有做任何特别的事情来将它们添加"到样式中,所有标记也都可以正常显示.

所以,我的代码不是问题,我的问题是关于默认样式上的maki图标的可用性.我本以为它们都可以在所有样式上使用,但似乎没有.

如何确定哪些图标可以在所有默认样式中使用(缺少反复试验)?有什么方法可以启用"样式中的所有图标?

如果没有,如果我必须制作自己的基本样式版本,我想可以,但是如何确保所有图标都已装入样式?

解决方案

标准的Mapbox样式已经过优化,并且不包含任何不需要显示它们的内容.因此,不包括样式本身未使用的图标.

创建新样式时,我认为Mapbox默认包含整个Maki集.

如果您可以直接修改样式文件(JSON),则可以尝试更改此行(对于Mapbox Streets样式):

 "sprite":"mapbox://sprites/mapbox/streets-v9", 

转换为您的一种自定义样式中的等价物,例如:

  sprite:" mapbox://sprites/woowoowoo/htd32t6hd236t, 

但是,如果Mapbox Street中有某些图标不是您的风格,则可能会导致问题.

简而言之,我认为没有添加所有图标"的简单方法.每种样式都有其自己的图标集.

更好的方法可能是在运行时使用 addImage / loadImage 加载所需的自定义图标.请参见此示例.

I'm trying to build a map which allows users to choose icons for their geojson points. I just want to use the default map styles (streets|outdoors|light|dark|satellite) and Maki icons, however, not all icons are showing on all styles.

For example 'bicycle' and 'cafe' show on all the map styles, 'circle' only shows on satellite, and 'marker' doesn't show on any of them.

On a style I developed for another purpose, all markers show fine even though I know I didn't do anything special to 'add' them to the style.

So, my code is not the problem, my question is about the availability of maki icons on the default styles. I would have thought they'd all be available on all styles, but it seems not.

How can I tell which icons will work across all the default styles (short of trial and error)? Is there some way I can 'enable' all the icons on a style?

Failing that, if I do have to make my own versions of the basic styles, I guess I can, but how do I ensure all the icons are loaded into the style?

解决方案

The standard Mapbox styles are fairly optimised, and don't include anything that's not needed to display them. So, icons that aren't used in the style itself aren't included.

When you create a new style, I think Mapbox by default includes the whole Maki set.

If you can modify the style file (JSON) directly, you could try changing this line (for the Mapbox Streets style):

"sprite": "mapbox://sprites/mapbox/streets-v9",

to the equivalent in one of your custom styles, something like:

sprite": "mapbox://sprites/woowoowoo/htd32t6hd236t",

But it might cause problems if there are icons in Mapbox Streets that aren't in your style.

In short, I don't think there's a simple way to add "all the icons". Each style has its own set of icons.

A better way might be to use addImage/loadImage to load the custom icons you want, at run time. See this example.

这篇关于Maki图标并非全部显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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