我读了MapBox和矢量图块,我想知道我是否理解这一点.
在某些未来,可以使用iOS MapBox渲染基于矢量的图块?如果是的话,矢量图块的RMTileSource会是什么样子?
通俗地说,我是否理解这一点:我将能够使用SVG甚至PDF文件作为MapBox的数据源而不是PNG图块?
如果是,是否还有可以试验的代码?
有一个latlng distanceTo方法:http: //leafletjs.com/reference.html#latlng
distanceTo( <LatLng> otherLatlng ) Number Returns the distance (in
meters) to the given LatLng calculated using the Haversine formula.
See description on wikipedia
Run Code Online (Sandbox Code Playgroud)
它计算两个LatLng之间的距离(以米为单位).但是,有时我需要知道两点之间有多少像素.有没有人有这个想法?
我正试图将文本标签置于mapbox-gl-js中的特征多边形上.这可能吗?看起来与标签放置相关的唯一选项是"符号放置"布局属性(https://www.mapbox.com/mapbox-gl-style-spec/#symbol):
符号位置
可选的枚举.其中一点,一线.默认为指向.标签相对于其几何体的位置.line只能在LineStrings和Polygons上使用.
使用"point"将标签放在功能的右下角:

想法?
在我填充了一个NSMutableArray对象并尝试用它做某事之后,它包含(id)0x0了一些索引.我认为NSMutableArray在Objective-C中根本不可能添加nil 所以我想知道为什么会发生这种情况.
不幸的是,"有时候".它可以通过下载超过5000个瓷砖来重现,只是为了获得足够高的金额以便发生这种情况.即使有超过5000个瓷砖,它有时也会完美无缺.
我的应用程序有一个按钮,可以开始下载特定区域的地图图块.下载在后台线程中并行发生,并为每个下载的磁贴报告.
为了允许取消下载,在我的下载器单例中,我有一个临时表NSMutableArray,可以保存每个下载的磁贴的哈希值.取消后,我可以使用该哈希列表删除数据库中的每个已保存的磁贴.
在下载过程中保存哈希似乎没问题,但是当我真的想要对它做任何事情时(我用[_currentTileHashes copy]它来改变它NSArray以给予删除方法),它会抛出NSInvalidArgumentException一行说:
-[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[3402]
Run Code Online (Sandbox Code Playgroud)
当我使用调试器检查_currentTileHashes可变数组时,我确实看到一个或两个索引实际上是nil或(id)0x0.这个截图说明了它:
此代码来自每个tile下载的回调,它会散列磁贴,将其添加到hashes数组并回调UI以获取进度:
- (void)tileCache:(RMTileCache *)tileCache didBackgroundCacheTile:(RMTile)tile withIndex:(NSUInteger)tileIndex ofTotalTileCount:(NSUInteger)totalTileCount {
DebugLog(@"Cached tile %lu of %lu.", (unsigned long)tileIndex, (unsigned long)totalTileCount);
if (_currentlyDownloading) {
float progress = (float)tileIndex / (float)totalTileCount;
NSDictionary *progressDict = @{@"progress" : [NSNumber numberWithFloat:progress],
@"routeId" : _downloadingRoute.routeId};
[_currentTileHashes addObject:[RMTileCache tileHash:tile]];
[[NSNotificationCenter defaultCenter] …Run Code Online (Sandbox Code Playgroud) 我目前正在使用leaflet.js并且我现在正在网上搜索相当多的内容,以找出:如果有事件,可以在异步函数setView()的动画结束后触发.
这是我试过的:
map.setView( [lat, lon ], 12 , {
pan: { animate: true , duration: 0.5 },
zoom: { animate: true },
animate: true
}.on('ready', function(e) {
console.log("animation finished!");
});
Run Code Online (Sandbox Code Playgroud)
setView-command工作正常,但是当map-animation准备就绪时应该触发的函数不起作用.
有没有人有办法解决吗?
我在为要素图层设置图标时遇到了一些问题.我不断得到layer.setIcon is not a function和类似的错误.如何更改此图层的图标样式?
var layer = L.mapbox.featureLayer()
.loadURL(attrs.geoJsonSource)
.addTo(map);
layer.on('ready', function() {
this.eachLayer(function(layer){
layer.setIcon(L.mapbox.marker.icon({
'marker-color': '#8834bb',
'marker-size': 'large',
'marker-symbol': 'restaurant'
}))
});
map.fitBounds(featureLayer.getBounds());
});
Run Code Online (Sandbox Code Playgroud) 我正在批量加载Geojson中的积分,并希望在积分首次出现在Mapbox中时添加"fadeIn"效果或动画.
this.map.addLayer({
id: 'points',
type: 'circle',
paint: {
'circle-radius-transition': {duration: 300},
'circle-color': '#F98200',
'circle-stroke-color': '#D23B00',
'circle-stroke-opacity': 0.5,
},
source: 'points',
})
Run Code Online (Sandbox Code Playgroud)
我试过circle-radius-transition但它似乎没有帮助.
我想将Mapbox导航集成到iOS中,我可以轻松获取两个坐标之间的方向/路线,也可以从Mapbox获取导航路径,我们可以使用以下代码
let options = NavigationOptions(styles: nil)
let viewController = NavigationViewController(for: self.directionsRoute!)
viewController.delegate=self
self.present(viewController, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
但是问题是我想在另一个视图控制器一部分的mapview中显示导航,我可以通过获取方向/路线和指令来做到这一点,但是找不到任何每秒都会被调用的方法,因此如果用户更改路径,我可以更新路径指令以及路径。
让我知道我是否遗漏任何东西或需要任何更改。
-提前致谢
我正在使用mapbox supercluster制作聚簇地图。我面临的问题是群集不在正确的位置。例如,我只养狗,the netherlands但缩小时它们在法国。
当我进一步放大时,星团缓慢地移动到荷兰。当我滚动时,簇在地图上移动。
在我的网站https://v2.sayhi.dog/?dog-map=true上可以看到问题。
我的代码如下所示(我使用vue.js):
<template>
<div class="w-full h-full" id="map"></div>
</template>
<script>
import mapboxgl from 'mapbox-gl'
import Supercluster from 'supercluster';
export default {
props: ['locations'],
data() {
return {
map: null,
copyLocations: this.locations,
clusters: [],
markers: [],
clustersGeojson: {},
clusterIndex: null,
}
},
mounted() {
mapboxgl.accessToken = 'my-token';
// init the map
this.map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/sayhi/cjkp9e59x3m3y2rm1zbcc0c',
zoom: 2,
});
this.addControls();
this.map.on("load", () => { this.addMarkers() });
this.map.addControl(new …Run Code Online (Sandbox Code Playgroud) hierarchical-clustering mapbox vue.js mapbox-gl mapbox-marker
我正在创建一个 React Mapbox 应用程序,但我遇到了弹出窗口问题。当我渲染地图时,所有标记都正确显示在地图上。然后我单击标记,该标记上会打开一个弹出窗口,其中包含正确的数据和所有内容。
但是,一旦我关闭该弹出窗口,我就无法打开新的弹出窗口。甚至不是同一个弹出窗口。我尝试 console.log() 单击时获得的数据,它是正确的(引脚数据对象:纬度、经度、id ...)
这是我的代码:
import { useState, useEffect } from "react";
import Map, { Marker, Popup } from "react-map-gl";
import axios from "axios";
import "mapbox-gl/dist/mapbox-gl.css";
import "./App.css";
import { Room } from "@material-ui/icons";
import { format } from "timeago.js";
function App() {
const [pins, setPins] = useState([]);
//Contains selected pin
const [selectedPin, setSelectedPin] = useState(null);
const [showPopup, setShowPopup] = useState(false);
//Get all pins from the database
useEffect(() => {
const getPins = async () => …Run Code Online (Sandbox Code Playgroud) mapbox ×10
mapbox-gl ×4
ios ×3
leaflet ×3
javascript ×2
mapbox-gl-js ×2
dictionary ×1
gis ×1
json ×1
mapbox-ios ×1
mbtiles ×1
navigation ×1
nsarray ×1
objective-c ×1
reactjs ×1
swift ×1
vue.js ×1