标签: mapbox

鼠标悬停时 Leaflet.js 折线颜色变化

我使用 Leaflet 中的点列表绘制了一个 polyLine。这是代码

road= new L.Polyline(pointList, {
    color: color,
    weight: 10,
    lineCap:"square",
    lineJoin:"bevel",
    opacity: 0.6,
    smoothFactor: 1
    }); 
Run Code Online (Sandbox Code Playgroud)

我需要在鼠标悬停时将此 polyLine 的颜色更改为绿色。我正在使用以下代码。但它不起作用。

road.on('mouseover', function (e) {
         var layer=e.target;
         layer.options["color"]="green";
         console.log(layer.options["color"]);

        });
Run Code Online (Sandbox Code Playgroud)

谁能给我任何想法我该怎么做?

leaflet mapbox

2
推荐指数
1
解决办法
4516
查看次数

传单:如何从单个集合中切换 GeoJSON 功能属性?

我有一个包含超过 2000 多个功能的 GeoJSON 对象,每个功能都属于一个类别(即“电气”、“军事”等)。总共有大约38个类别。

这是我的集合的架构示例:

{"type":"Feature","properties":{"category":"Electrical","Name":"Plant No 1"},"geometry":{"type":"Point","coordinates":[81.73828125,62.59334083012024]}},{"type":"Feature","properties":{"category":"Electrical","Name":"Plane No 2"},"geometry":{"type":"Point","coordinates":[94.5703125,58.722598828043374]}},{"type":"Feature","properties":{"category":"Military","Name":"Base 1"},"geometry":{"type":"Point","coordinates":[104.4140625,62.91523303947614]}}
Run Code Online (Sandbox Code Playgroud)

这是我遍历集合的 L.geoJson 函数:

var allPoints = L.geoJson(myCollection, {
    onEachFeature: function(feature, layer){
        layer.bindPopup(L.Util.template(popTemplate, feature.properties));
    },
    "stylel": function(feature){
        return { "color": legend[feature.properties.category]
    }
}}).addTo(map);
Run Code Online (Sandbox Code Playgroud)

如何将每个category属性分配给我的 L.control 函数,以便用户可以打开/关闭集合中的各种类别?如果我将每个类别都设为一个数据集和一个单独的 geoJSOn 层,我就可以做到这一点,但是要完成所有 38 个类别的工作量太大了。

我的尝试:

L.control.layers({
    'Street Map': L.mapbox.tileLayer('mapbox.streets').addTo(map)
},{
    'Electrical': myCollection[feature.properties.category["Electrical"]],
    'Military': myCollection[feature.properties.category["Military"]]
});
Run Code Online (Sandbox Code Playgroud)

有一个更好的方法吗?谢谢!

leaflet mapbox

2
推荐指数
1
解决办法
2162
查看次数

如何获取从当前位置到下一步的距离、方向、持续时间?

我正在使用 Mapbox Android SDK

compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:3.0.0@aar').

我之前在这里问过类似的问题,但仍然有一些问题。拿到currentRoute的时候不知道怎么实现。我的代码如下:

private Waypoint lastCorrectWayPoint;
private boolean checkOffRoute(Waypoint target) {
    boolean isOffRoute = false;
    if(currentRoute != null){
        if (currentRoute.isOffRoute(target)) {
            showMessage("You are off-route, recalculating...");
            isOffRoute = true;
            lastCorrectWayPoint = null;
            //would recalculating route.
        } else {
            lastCorrectWayPoint = target;
            String direction = "Turn right"; //The message what should I prompt to user
            double distance = 0.0;//The distance which from target to next step.
            int duration = 0;//The time which from target to …
Run Code Online (Sandbox Code Playgroud)

java android mapbox

2
推荐指数
1
解决办法
1490
查看次数

Mapbox 中的 MKUserTrackingBarButtonItem

我正在评估从 MapKit 切换到 Mapbox。

我已经找到了所有函数的等效项,除了MKUserTrackingBarButtonItem.

let trackingButton = MKUserTrackingBarButtonItem(mapView: map)
Run Code Online (Sandbox Code Playgroud)

有没有办法为 Mapbox iOS SDK 创建这个按钮?

我在 Mapbox 文档中没有找到类似的东西,我不能继续使用这个函数,因为它需要一个MKMapView.

提前致谢。

mapkit ios mapbox swift swift2

2
推荐指数
1
解决办法
774
查看次数

Mapbox开源并使用密钥?

我已经浏览了 MapBox 的开源库,主要对使用mapbox-gl-js感兴趣

但是,我无法理解为什么我需要在开源库中使用 mapbox 的密钥。它是为使用密钥而构建的,否则我不能吗?我想使用这个库作为我公司的原型,并想确定其含义是什么。

javascript maps mapbox mapbox-gl-js

2
推荐指数
1
解决办法
543
查看次数

如何解析关于 Mapbox 矢量瓦片地图的 *.vector.pbf?

  1. *.pbf("Protocolbuffer Binary Format") 主要用于替代 XML 格式。
  2. 有两种格式*.osm.pbf*.vector.pbf。我可以使用哪些工具打开这些文件?(我知道JOSM可以打开 *.osm.pbf 文件,但它不能打开 *.vector.pbf 文件。)
  3. 如果我想在 Mapbox 中编写自己的 *.vector.pbf 文件,我该如何工作?

谢谢!

openstreetmap mapbox osm.pbf

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

绘制折线 MapBox,iOS

我正在使用 Mapbox iOS SDK 创建一个带有路线的简单应用程序,并试图找出如何在没有 geojson 的情况下绘制折线。首先,我尝试使用此方法获取路线:

 func getRoute(directionsRequest: MBDirectionsRequest){

    let directionsRequest = MBDirectionsRequest(sourceCoordinate: pointOne.coordinate, destinationCoordinate: pointTwo.coordinate)
    directionsRequest.transportType = .Automobile

    let directions = MBDirections(request: directionsRequest, accessToken: "pk.eyJ1IjoidXJiaWNhIiwiYSI6ImNpb2xkNndvMjAwMW13cW1ibmY4Z2t3NHcifQ.3wadKQBcytWcJVY1eUSVWQ")


    directions.calculateDirectionsWithCompletionHandler({ (response: MBDirectionsResponse?, error: NSError?) -> Void in

        if error != nil {
            print(error)
        } else {
            self.myRoute = response?.routes.last
            print(self.myRoute?.destination.coordinate)
            self.drawRoute(self.myRoute!)
        }

    })
}
Run Code Online (Sandbox Code Playgroud)

之后试图绘制一条路线,但它不起作用。

func drawRoute(myRoute: MBRoute){
    let waypoints = myRoute.waypoints

    var coordinates: [CLLocationCoordinate2D] = []

    for point in waypoints {

        let coordinate = CLLocationCoordinate2DMake(point.coordinate.latitude, point.coordinate.longitude)
        coordinates.append(coordinate)
    }

    let line = …
Run Code Online (Sandbox Code Playgroud)

ios mapbox swift

2
推荐指数
1
解决办法
3404
查看次数

在swift 3.0中将坐标数组转换为geojson字符串

有没有办法轻松地将我的坐标数组转换为 geojson 字符串,以便我可以轻松地在 mapbox-ios 地图中绘制它?

id: 1, lat: 37.54365964, lon: -122.36820328, date: 1483607009.98252
id: 2, lat: 37.63721702, lon: -122.43994642, date: 1483607387.95026
id: 3, lat: 37.64117709, lon: -122.44319877, date: 1483607403.98835
id: 4, lat: 37.64425086, lon: -122.44768593, date: 1483607419.95671
id: 5, lat: 37.64803999, lon: -122.45107063, date: 1483607435.98718
id: 6, lat: 37.65210789, lon: -122.45382878, date: 1483607451.98202
id: 7, lat: 37.65538199, lon: -122.45796869, date: 1483607467.99542
id: 8, lat: 37.65874435, lon: -122.46226986, date: 1483607483.98868
id: 9, lat: 37.66271988, lon: -122.46545406, date: 1483607500.00689
id: 10, lat: …
Run Code Online (Sandbox Code Playgroud)

geojson mapbox swift3

2
推荐指数
1
解决办法
1943
查看次数

如何在mapbox导航控件中只显示+和-

我正在使用以下代码行在我的地图上显示导航控件:

  map.addControl(new mapboxgl.NavigationControl());
Run Code Online (Sandbox Code Playgroud)

它显示了 Zoom in + 和 Zoom out - 选项,这些选项很棒,但它还显示了放大和缩小按钮下方的倾斜图选项。我想删除它,只显示放大和缩小选项。这似乎很容易解决,但我无法在我的研究中提出答案。

mapbox

2
推荐指数
1
解决办法
2533
查看次数

How to integrate Mapbox SDK with SwiftUI

I installed the Mapbox SDK into my project, but I don't understand how to integrate this code snippet with SwiftUI.

I created a SwiftUI View named MapView, where I import the Mapbox Framework.

I try to use the UIViewRepresentable protocol, as in Apple's tutorial, but without success.

import Mapbox

class MapView: UIViewController {

  override func viewDidLoad() {
    super.viewDidLoad()

    let styleURL = URL(string: "mapbox://styles/mapbox/outdoors-v9")
    let mapView = MGLMapView(frame: view.bounds,
                             styleURL: styleURL)
    mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]

    mapView.setCenter(CLLocationCoordinate2D(latitude: 45.52954,
                                             longitude: -122.72317), …
Run Code Online (Sandbox Code Playgroud)

mapbox swift swiftui

2
推荐指数
1
解决办法
344
查看次数