使用高德地图根据经纬度画出路线、计算收录路线的总距离、使用第三方工具获取坐标信息

写在前面:

       最近手里有一个项目 项目面向的使用群体是公路管理方 大概的主要功能简概如下

收录正在修建 / 刚刚修建完毕 / 未被第三方地图收录的路线(用户可以手机记录新的路线 收录在自己的平台里 但手机记录弊端过大 还是建议web端手动捕获 这里演示的是web捕获数据)

将收录到的公路信息作为内部参照 在后期公路状况监察、维护、路况查询等方面使用 

上结果图

图一、使用第三方网站采集自己需要采集的线路 我在这里使用了已有的线路描绘了一下 方便演示​​​

     图二、下载采集到的经纬度信息​​​

     图三、将采集到的信息上传到自己的后台 然后将数据处理之后 以供后期使用调起

​​​

​​​

​​​

到这里图片演示完毕 上代码

html代码

<!doctype html>

<html>

<head>

    <meta charset="utf-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">

    <style>

    html,

    body,

    #container {

      width: 100%;

      height: 100%;

    }

    </style>

    <title></title>

    <link rel="stylesheet" href="https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css" />

    <script src="https://webapi.amap.com/maps?v=1.4.11&058e94789b10cda41888b34030c68aa8&plugin=AMap.PolyEditor"></script>

    <script src="https://a.amap.com/jsapi_demos/static/demo-center/js/demoutils.js"></script>

</head>

<body>

<div id="container"></div>

<div class="input-card" style="width: 120px">

  <button class="btn" onclick="polyEditor.open()" style="margin-bottom: 5px">开始编辑</button>

  <button class="btn" onclick="polyEditor.close()">结束编辑</button>

</div>

<script type="text/javascript">


    var map = new AMap.Map("container", {

        center: [116.398597, 39.913257],

        zoom: 14

    });

    map.plugin(["AMap.ToolBar"], function() {

        map.addControl(new AMap.ToolBar());

    });

    var path = [{$lnglat}];

    var polyline = new AMap.Polyline({

        path: path,

        isOutline: true,

        outlineColor: '#ffeeff',

        borderWeight: 3,

        strokeColor: "#3366FF",

        strokeOpacity: 1,

        strokeWeight: 6,

        // 折线样式还支持 'dashed'

        strokeStyle: "solid",

        // strokeStyle是dashed时有效

        strokeDasharray: [10, 5],

        lineJoin: 'round',

        lineCap: 'round',

        zIndex: 50,

    })

    polyline.setMap(map)

    // 缩放地图到合适的视野级别

    map.setFitView([ polyline ])

    var polyEditor = new AMap.PolyEditor(map, polyline)

    polyEditor.on('addnode', function(event) {

        log.info('触发事件:addnode')

    })

    polyEditor.on('adjust', function(event) {

        log.info('触发事件:adjust')

    })

    polyEditor.on('removenode', function(event) {

        log.info('触发事件:removenode')

    })

    polyEditor.on('end', function(event) {

        log.info('触发事件: end')

        // event.target 即为编辑后的折线对象

    })

</script>

</body>

</html>


php代码(上传直接上传 查看时处理文件 每次查看时读文件 处理出自己所需的格式数据 每次查看去处理效率不高 后期再改 先放代码)

/**

*  拼出路径 查询出上传文件 读文件

*/

$file_path = substr(APP_PATH, 0, strrpos(APP_PATH, '..')).'uploads/'.$result['secret_img'];

if(file_exists($file_path)){

$fp = fopen($file_path,"r");

$str = fread($fp,filesize($file_path));//指定读取大小,这里把整个文件内容读取出来

// echo $str = str_replace("\r\n","<br />",$str);

$lnglat = substr($str, stripos($str, '[[')+1,stripos($str, '}}') - stripos($str, '[[')-2);

fclose($fp);

$this->assign('lnglat',$lnglat);

return view();

----- 未完待续(未加线路距离计算)

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • mean to add the formatted="false" attribute?.[ 46% 47325/...
    ProZoom阅读 7,898评论 0 3
  • 前言 最先接触编程的知识是在大学里面,大学里面学了一些基础的知识,c语言,java语言,单片机的汇编语言等;大学毕...
    oceanfive阅读 8,472评论 0 7
  • 上回发布的时候,没有对代码进行说明,其实这段代码的主要功能是这样的,根本你从后台所得到的坐标点进行数据展示,并且 ...
    你的爱Imnot阅读 6,200评论 0 1
  • 瑜伽1小时 上周二上完普拉提后全身肌肉酸痛,导致到现在全身都觉得无力,对运动充满了恐惧。今天测了体重...
    九九运阅读 3,468评论 0 0
  • 很多时候想起一些褪色的故事,都会觉得木然。也怀疑起昨日的阳光,怀疑起背包的褶痕。 2017年7月12日我还是来到...
    浅灰蓝阅读 1,810评论 0 0

友情链接更多精彩内容