问题标签 [mapbox]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
4 回答
32167 浏览

php - 从 MySql 在 php 中创建 GeoJson 以与 MapBox javascript API 一起使用

我想做的很简单;使用我的 PHP 代码从 Mysql 表中获取标记的数据,将其转换为 geoJson(由 MapBox 使用),将该 geoJson 发送到 javascript,然后将这些标记填充到我的地图中。

我一直在非常仔细地阅读以下两个链接,其中显然包含解决此问题所需的所有信息,但我不确定我缺少什么。

在这里,您可以看到有关如何从 MapBox 中的 geoJson 填充标记的示例;

在这里,您可以看到如何从 MySql 表中创建 geoJson;

我的sql表是这样的,这里是创建代码加上一些虚拟数据;

所以这是我的 php 代码,我从数据库中获取数据并创建一个 GeoJson。

只是为了测试这一点,如果这里的“echo json_encode($marker)”是一个示例输出;

现在这是javascript代码的样子;

最后是实际显示地图但不显示标记的完整 HTML;

那么,我错过了什么?我注意到的一件事是我的 geoJson 的输出在几何数组中有 ",而在 MapBox 示例中使用的那个没有;

谁能帮我?没有任何真正的复杂性,我认为这只是数据格式问题或我将 GeoJson 发送到 JS 的方式。

提前致谢!

我刚刚注意到这条线;

应该;

在这种情况下,结果是;

0 投票
1 回答
167 浏览

javascript - Google Maps API + Wax.g + IE = Tiny Tiles

I'm using wax.g to display custom tiles on a Google Map. This works fine in every browser I've tested, except IE. In other browsers, the tiles are rendered correctly, but in IE, the tiles a rendering as a smaller version of their true selves. The issue is best explained in the following screenshots:

What they should look like: http://cl.ly/image/2E0U2b0c0f0W

What they look like in IE: http://cl.ly/image/2F3B353q0G0c

This issue doesn't happen all the time, and if I pan or zoom, sometimes I get the correctly sized tiles, and sometimes I don't. Not sure if this is a Wax issue or an issue with how the Google Maps API renders custom overlayMapTypes. Has anyone else experienced this issue? Any insight is much appreciated...

(cross-posted from MapBox GitHub issue - no answers there yet)

0 投票
1 回答
7166 浏览

leaflet - Leaflet / Mapbox 渲染问题(灰色区域)

出于某种原因,我的地图上有一个很大的灰色区域,直到我移动它使它出现。

但乍一看,少了一部分。我以前在网上看到过很多这种情况,但直到现在才想知道如何解决它。

这是一个使用 MarkerClusterGroup 集群的简单 Mapbox 地图。

这是屏幕截图和页面链接: 在此处输入图像描述

http://vinpin.com/map

所以我想知道,对于这种行为有什么简单的已知解决方法吗?

如果需要,我可以添加代码片段。

感谢,并有一个愉快的一天!

0 投票
1 回答
1674 浏览

json - Publishing MBTiles online, issue with .json file or mb-util extraction

I've been trying to display my .mbtiles on the browser inside a "map-div". I extracted the .mbtiles into .png tile files and a .json file using mb-util

This is how my server's public_html looks like: enter image description here

Tiles folder: enter image description here

metadata.json inside tiles folder: enter image description here

And main javascript file java.js: enter image description here

Inside java.js there's the code from the Wax connector so I can use the .json to work with Leaflet.

The map in this state does not work.

So I uploaded the mbtiles file to the MapBox hosting and fetch the .json URL. And when the URL http://testit969.host22.com/tileserver/century.json in java.js is replaced by the Mapbox generated .json URL, it displays the map (although the interactivity doesn't work). This shows me at least that the code is sufficient to display a map provided the .json file is OK.

But right now, the map doesn't display at all. It displays the Leaflet map container only in gray.

Any help would be appreciated.

0 投票
6 回答
6118 浏览

javascript - 触摸时 MapBox 滚动页面

我正在尝试在填充 100% 页面的布局上实现 MapBox。我已经禁用了地图缩放选项,但是当尝试在地图填充视口的触摸设备上滚动时出现问题。我可以覆盖它还是让浏览器将其视为图像?

0 投票
1 回答
533 浏览

maps - 具有大量边界的交互式地图

我正在尝试从输出区域文件中创建一个交互式地图(我可以在其中放大/缩小,显示弹出窗口和信息框):输出区域(E+W)2011 边界(广义,裁剪)。此文件包含英格兰和威尔士的 181,408 个输出区域 (OA) 的数字矢量边界。

Shapefile 约为 80MB,geojson 约为 210MB,topojson 约为 39MB(简化版)。我无能为力来降低 topojson 的大小。我一直在尝试创建传单地图,但文件仍然太大而无法在浏览器中加载。我还按照本教程使用 TileMill、Leaflet 和 Wax 使用我自己的图块创建地图。不幸的是,为合理的缩放范围生成的图块仍然 > 100GB。

有谁知道我如何加载边界并且仍然能够放大/缩小?可能使用开源技术?

0 投票
2 回答
1017 浏览

json - 使用 Wax 和 Leaflet 加载本地 TileJSON 时出现语法错误

我有这个 TileJSON 文件:

我正在使用以下代码创建地图:

当我在浏览器中执行脚本时,出现以下错误:

我遵循了 TileJSON 规范,并且在文件中没有发现拼写错误/其他问题。我清除了浏览器缓存,并且我 100% 确定我正在加载正确的文件。我已经尝试删除一些键/值,但问题仍然存在。

我将不胜感激有关如何在本地加载瓷砖的任何建议。

0 投票
2 回答
376 浏览

ios - 将 mapkit 注释对象转换为 mapbox 注释对象

我正在我的应用程序中使用 MapBox 实现离线地图,该应用程序当前将 mapkit 与 Apple Maps 一起使用。

我有一个描述兴趣点的对象 - 名称、描述位置等,其界面如下所示:

上面的对象被添加到一个数组中,然后被添加到 mapkit 中,如下所示:

但是,在处理 MapBox 地图视图时,我无法像上面那样添加 MKAnnotation 对象,因为它需要 RMAnnotation 对象。但是,当我将界面更改为 read- <RMAnnotation>而不是时<MKAnnotation>,它似乎不存在。

我在文档中找不到任何关于如何添加这样的注释的内容。像这样尝试这样做会很好,这样我就可以处理回调并知道哪个注释被点击了等等!

0 投票
1 回答
865 浏览

javascript - Mapbox 标记属性更新:为什么这不起作用?

使用 Mapbox JS API 并想知道为什么缓存在变量中的标记属性不会更新,但它们的非缓存对应物会更新。

例如,这将按state预期更新标记的自定义属性(在其他地方的 geoJSON 对象中定义):

但这不会:

谁能帮我理解后者发生了什么?为什么我不能缓存变量中的引用而不是e.layer.feature.properties['state']每次都更新?

0 投票
1 回答
5500 浏览

javascript - 在 Mapbox 中重置我所有的 markerLayer

我使用 Mapbox 作为地图来显示公司 geoLoc,我的代码是

我的问题是当我收到一个新的 json 调用并返回新位置时,我不知道如何重置/删除所有旧的 markerLayer,它只是将所有新的添加到地图中。

我已经创建了一个地图 obj。宽度 jQuery,$.mapbox.mapObj所以我希望它可以从我的对象中重置/删除我所有的 markerLayers,我可以在它上面添加我所有的新 markerLayers。