从坐标数组中读取数据在地图中实时打点,第一个点与第一个点相隔5秒钟
<?php $content = file_get_contents("http://web.cellpies.com/api/driving/getVehicleLocationPoints?vehicleDeviceId=0400000000030603&timeType=4&startTime=2017-03-17%2013:00:00&stopTime=2017-03-17%2014:00:00"); $data = json_decode($content); for($i=0;$i<1;$i+=1){ //echo '编号:'.$data->data[$i]->time.'<br>'; $gpsx=$data->data[$i]->gpsx; $gpsy=$data->data[$i]->gpsy; echo <<<_END <!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"> <title>点标记</title> <link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css"/> <script src="js/addMarker.js" type="text/javascript"></script> <style> .marker { color: #ff6600; padding: 4px 10px; border: 1px solid #fff; white-space: nowrap; font-size: 12px; font-family: ""; background-color: #0066ff; } </style> <script src="http://webapi.amap.com/maps?v=1.3&key=您申请的key值"></script> <script type="text/javascript" src="http://cache.amap.com/lbs/static/addToolbar.js"></script> </head> <body> <div id="container"></div> <script> //在前一个script体中调用后一个script体中的函数出现问题,如需调用可能应在同一个script体中 var marker, map = new AMap.Map("container", { resizeEnable: true, center: [116.397428, 39.90923], zoom: 13 }); if($i==0) addMarker(116.397428, 39.90923); setTimeout("updateMarker(116.391467,39.947761)","5000"); </script> </body> </html> _END; } ?>