标签: mapbox

在mapbox/leaflet上聚类标记

我试图建立在mapbox集群地图,像http://leaflet.github.io/Leaflet.markercluster/example/marker-clustering-realworld.388.html

但他们的示例使用普通的.js文件作为数据 http://www.mapbox.com/mapbox.js/assets/realworld.388.js

我可以从mapbox唯一得到的是.geojson http://api.tiles.mapbox.com/v3/thebteam.map-w9jzcznw/markers.geojson

有没有办法可以将geojson转换为js(定期)?或者从mapbox导出javascript数组?

编辑:最终将我的数据切换为CSV并找到解析器.这是有效的代码,如果有人需要它:

var url = 'https://docs.google.com/spreadsheet/pub?key=abc123';

$.get(url, function(data) {
  var addressPoints = $.csv.toArrays(data);
  var map = L.mapbox.map('map', 'map-abc123').setView([20.30, 18.98], 2);
  var markers = new L.MarkerClusterGroup({ showCoverageOnHover: false });

  for (var i = 0; i < addressPoints.length; i++) {
    var a = addressPoints[i];
    var title = a[2];
    var marker = L.marker(new L.LatLng(a[0], a[1]), {
      icon: L.mapbox.marker.icon({'marker-size': 'small', 'marker-color': 'e8168c'}),
      title: title
    });
    marker.bindPopup(title);
    markers.addLayer(marker);
  }

  map.addLayer(markers);

});
Run Code Online (Sandbox Code Playgroud)

javascript json geojson leaflet mapbox

7
推荐指数
2
解决办法
6383
查看次数

MapBox在iOS位置添加交互式注释/视图

我正在尝试实现MapBox地图,使用它的特殊原因,它是高度可定制的,我需要创建一个具有所有不同颜色的不同类型的地图,我得到了完美的工作.

问题我想在地图上添加一个应该从内部交互的注释,通常一个注释是交互式的,只需点击它就可以了,它有效,我需要注释中的UIButton,点击Button动作应该执行.

问题 如何使用MapBox中的按钮/视图创建注释,我应该如何处理.

任何帮助表示赞赏.

谢谢.

编辑:

更准确地说,我想要下面的图像 在此输入图像描述 用于注释..

annotations objective-c map ios mapbox

7
推荐指数
1
解决办法
3529
查看次数

在MapBox中加载geoJson,以便使用Leaflet.Draw进行编辑

我尝试在Mapbox中加载geoJson数据并使用插件Leaflet.Draw对其进行编辑

这是一个例子:小提琴

var featureGroup = L.featureGroup().addTo(map);

var geojson = {
  "type": "FeatureCollection",
  "features": [ ...........  ]
}


L.geoJson(geojson).addTo(featureGroup);
Run Code Online (Sandbox Code Playgroud)

当我点击编辑按钮时,我有一个错误:

未捕获的TypeError:无法读取未定义的属性"enable"

对象似乎是可编辑的,但我无法修改它.

在mapbox 绘图层中添加geojson对象的正确方法是什么?

geojson leaflet mapbox

7
推荐指数
1
解决办法
3732
查看次数

对Mapbox注释进行排序

我目前正在寻找使用mapbox对所有注释进行排序.

我知道我应该使用以下过程:

//implementing this method and do the sort here   
(NSComparator)annotationSortingComparatorForMapView:(RMMapView *)mapView

// remove current annotation and use the sorted array to redraw them
[mapView removeAnnotations:[mapView annotations]];
[mapView addAnnotations:annotationSorted];
Run Code Online (Sandbox Code Playgroud)

这里的问题是我迷失了我应该称之为这个过程的地方.

我实际上是mapView:layerForAnnotation:用来返回应该绘制的形状,但如果我没有错,那么它是一个回调,所以不是从代码中调用的.

谢谢你的帮助.

编辑:

感谢jszumski,我想出了一个实现.对于那些在未来需要它的人来说,它是:

- (NSComparator)annotationSortingComparatorForMapView:(RMMapView *)RmapView
{
    NSComparator sort =^(RMAnnotation *annotation1, RMAnnotation *annotation2)
    {
        // Sort user location annotations above all.
        //
        if (   annotation1.isUserLocationAnnotation && ! annotation2.isUserLocationAnnotation)
            return NSOrderedDescending;

        if ( ! annotation1.isUserLocationAnnotation &&   annotation2.isUserLocationAnnotation)
            return NSOrderedAscending;

        // Amongst user location annotations, sort properly.
        //
        if …
Run Code Online (Sandbox Code Playgroud)

sorting objective-c ios mapbox

7
推荐指数
1
解决办法
325
查看次数

如何使用单点+多边形在GeoJSON中创建GeometryCollection?

如何将点作为单个要素添加到多边形?根据GeoJson规范,这被称为"GeometryCollection".

'GeometryCollection'的示例:

{ "type": "GeometryCollection",
"geometries": [
  { "type": "Point",
    "coordinates": [100.0, 0.0]
    },
  { "type": "LineString",
    "coordinates": [ [101.0, 0.0], [102.0, 1.0] ]
    }
 ]
}
Run Code Online (Sandbox Code Playgroud)

我尝试在多边形特征中添加一个点,但我无法在地图集地图上显示它,因为我猜它是无效的GeoJson.

任何人都知道这样做的正确方法是什么?网上没有太多的例子可供使用.

我的看法:[jsfilddle]

var myRegions = {
 "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometries": [
        {
            "type": "Point",
            "coordinates": [
            61.34765625,
            48.63290858589535
            ]
      },
        {
        "type": "Polygon",
        "coordinates": [
          [
            [
              59.94140624999999,
              50.65294336725709
            ],
            [
              54.931640625,
              50.90303283111257
            ],
            [
              51.943359375,
              51.04139389812637
            ],
            [
              50.9765625,
              48.19538740833338
            ],
            [
              52.55859375,
              46.46813299215554 …
Run Code Online (Sandbox Code Playgroud)

geojson leaflet mapbox

7
推荐指数
2
解决办法
9677
查看次数

如何在mapbox的mapView上检测是否点击了singleTap?

iOS上的mapBox地图需求.(我不是在谈论MKMapView)我们如何检测是否在mapView上点击了singleTap或注释?我需要singleTap仅在地图的空白区域(没有引脚)处理,并且当我点击引脚时调用didSelectAnnotation.

但我在android上发现我们有这样的方法

mapboxMap.setOnMapClickListener(new MapboxMap.OnMapClickListener() {
            public void onMapClick(@NonNull LatLng point) {
                Toast.makeText(getActivity(),"on Tap "+point.getLatitude(),Toast.LENGTH_LONG).show();
            }
        });
Run Code Online (Sandbox Code Playgroud)

以及那个

mapboxMap.setInfoWindowAdapter(new MapboxMap.InfoWindowAdapter() { ... }) 将显示注释.

我们在iOS中没有相同的概念吗?

实际的问题是,在iOS的是,当我添加singleTapGestureMapbox的MapView的

UITapGestureRecognizer *singleTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];
[self.mapView addGestureRecognizer:singleTapGesture];
Run Code Online (Sandbox Code Playgroud)

mapboxmapView的委托方法不会调用.

- (nullable UIView <MGLCalloutView> *)mapView:(MGLMapView *)mapView calloutViewForAnnotation:(id <MGLAnnotation>)annotation;
Run Code Online (Sandbox Code Playgroud)

要确保委托方法必须调用,那么我不必使用 singleTapGesture

这里的情况要么是这个,要么就是这样,但根据我的需要,我需要两者.

期待任何解决方案.谢谢,

objective-c ios mapbox mapbox-gl

7
推荐指数
2
解决办法
3269
查看次数

如何将OpenMapTiles服务器用于MapBox GL JS?

在OpenMapTiles的文档中,它可以为MapBox GL JS提供矢量图块。

但是在挖掘这两个项目的文档时,我没有找到一个选择:如何配置自托管的MapBox GL JS库以使用自托管的OpenMapTiles服务器中的图块?

javascript mapbox mapbox-gl-js openmaptiles

7
推荐指数
1
解决办法
2202
查看次数

如何免费使用Leaflet Map?

宣传单是开源的,免费的.但是,传单站点上的示例使用Mapbox来渲染地图.Mapbox比谷歌地图(Mapbox定价)更贵.问题是:任何人都可以免费使用Leaflet吗?

google-maps leaflet mapbox

7
推荐指数
1
解决办法
4432
查看次数

在Mapboxgl中在线显示方向箭头

尝试在mapboxgl中显示箭头以指示方向。该箭头仅在高缩放时可见,而在低缩放时不可见。

使用添加图像图层 'symbol-placement': 'line'

线层

  map.addLayer({
          'id': 'route',
          'type': 'line',
          'source': 'mapSource',
          'filter': ['==', '$type', 'LineString'],
          'layout': {
            'line-join': 'round',
            'line-cap': 'round'
          },
          'paint': {
            'line-color': '#3cb2d0',
            'line-width': {
              'base': 1.5,
              'stops': [[1, 0.5], [8, 3], [15, 6], [22, 8]]
            }
          }
        });
Run Code Online (Sandbox Code Playgroud)

箭头层

const url = 'img/arrow.png'
    map.loadImage(url, (err, image) => {
      if (err) { return; }
      map.addImage('arrow', image);
      map.addLayer({
        'id': 'arrowId',
        'type': 'symbol',
        'source': 'mapSource',
        'layout': {
          'symbol-placement': 'line',
          'symbol-spacing': 1,
          'icon-allow-overlap': true,
          // 'icon-ignore-placement': true,
          'icon-image': 'arrow', …
Run Code Online (Sandbox Code Playgroud)

leaflet mapbox mapbox-gl-js

7
推荐指数
1
解决办法
2906
查看次数

mapbox gl js有空闲事件吗?

我需要某种谷歌地图"空闲"事件为mapbox gl.当每个事件都被触发并且地图停止了zoomin/out拖动等并且每个图层都已加载,并且地图处于空闲状态.我必须使用此代码

  map.on("render", function(e) {
            if(map.loaded() && triggerOnce === true) {
//fires on zoomin runing
                triggerOnce = false;
                console.log("Render end")
                setTimeout(somefunc(),1000)
            }
          })
Run Code Online (Sandbox Code Playgroud)

mapbox mapbox-gl

7
推荐指数
1
解决办法
779
查看次数