doujin8476 2017-01-08 19:48
浏览 78

OSM:两点之间的编程线进展

For an exercise/project in PHP, I have to program a route (with progression), but without being precise to the streets to be borrowed (as we know on GPS) but with lines between two points. Example: example route

The additional difficulty is to be able to display the progress on the line, starting from a percentage, the goal is therefore to have an image (like car, man or bicycle) on the straight line. I have already worked with leaflet.js, but if another library is more appropriate I am taker.

I use this for the moment, for the points (Departure and arrival):

function placeMarkerDepartureArrival() {
    // Departure
    L.marker([varGPS[0].lat, varGPS[0].lng], {icon:myIconAD}).addTo(map);
    // Arrival
    L.marker([varGPS[1].lat, varGPS[1].lng], {icon:myIconAD}).addTo(map);
}

If you have any examples or site, I am taker.

  • 写回答

1条回答 默认 最新

  • doulu8847 2017-01-10 11:23
    关注

    Mapbox.js (based on the leaflet mapping library) has examples of animation and plotting lines on their documentation website, and has free tier for your exercise/project

    Animating a point over a line

    From the mapbox.js site:

    map.addSource('point', {
        "type": "geojson",
        "data": pointOnCircle(0)
    });
    
    map.addLayer({
        "id": "point",
        "source": "point",
        "type": "circle",
        "paint": {
            "circle-radius": 10,
            "circle-color": "#007cbf"
        }
    });
    
    function animateMarker(timestamp) {
        // Update the data to a new position based on the animation timestamp. The
        // divisor in the expression `timestamp / 1000` controls the animation speed.
        map.getSource('point').setData(pointOnCircle(timestamp / 1000));
    
        // Request the next frame of the animation.
        requestAnimationFrame(animateMarker);
    }
    
    // Start the animation.
    animateMarker(0);
    

    Link to example

    评论

报告相同问题?

悬赏问题

  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图2.0 版本点聚合中Marker的位置无法实时更新,如何解决呢?
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题