地图高度控制html,带高度的点-点 Points-示例中心-JS API 示例 | 高德地图API

Points 带高度的点

html, body, #container {

margin: 0; padding: 0; width: 100%; height: 100%;

}

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

viewMode: '3D',

turboMode: false,

defaultCursor: 'pointer',

showBuildingBlock: false,

expandZoomRange: true,

zooms: [3, 20],

zoom: 4,

pitch: 50,

forceVector: true,

});

var object3Dlayer = new AMap.Object3DLayer({ zIndex: 110, opacity: 1 });

map.add(object3Dlayer);

function lnglatToG20(lnglat) {

lnglat = map.lngLatToGeodeticCoord(lnglat);

lnglat.x = AMap.Util.format(lnglat.x, 3);

lnglat.y = AMap.Util.format(lnglat.y, 3);

return lnglat;

}

new AMap.DistrictSearch({

subdistrict: 1, //返回下一级行政区

extensions: 'base'

}).search('中国', function (status, result) {

var provinces = result.districtList[0].districtList;

var points3D = new AMap.Object3D.Points();

points3D.transparent = true;

var geometry = points3D.geometry;

for (var p = 0; p < provinces.length; p += 1) {

// points 类型的顶点坐标需要使用 G20 坐标

var center = lnglatToG20(provinces[p].center);

// 随机高度。Z 轴正方向指向地下,因此这里设置高度要添加负号指向反方向

geometry.vertices.push(center.x, center.y, -Math.random() * 10000000);

geometry.pointSizes.push(Math.round(Math.random() * 50));

geometry.vertexColors.push(p * 0.029, p * 0.015, p * 0.01, 0.5);

// geometry.pointAreas.push(0.3,0,0.7,0.5);

}

points3D.borderColor = [0.6, 0.8, 1, 1];

points3D.borderWeight = 3;

object3Dlayer.add(points3D);

});

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是 PHP 使用高德地图 API 进行轨迹纠偏的示例代码: ```php <?php // 配置项 $key = 'your-key'; // 高德地图 API Key $url = 'https://restapi.amap.com/v5/assistant/trajectory/correct'; // API URL $file = 'path/to/gps-data.json'; // GPS 数据文件路径 // 加载 GPS 数据 $data = json_decode(file_get_contents($file), true); // 构造请求参数 $param = array( 'key' => $key, 'output' => 'json', 'spatial_accuracy' => 'high', // 纠偏精度,可选值:low、medium、high,默认为 high 'correct_tilt' => true, // 是否校正方向角,默认为 true 'points' => array(), ); foreach ($data['locations'] as $location) { $point = explode(',', $location); $param['points'][] = array( 'longitude' => $point[0], // 经度 'latitude' => $point[1], // 纬度 'speed' => isset($point[2]) ? $point[2] : null, // 速度 'accuracy' => isset($point[3]) ? $point[3] : null, // 精度 'timestamp' => isset($point[4]) ? $point[4] : null, // 时间戳 ); } // 发送请求 $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($param)); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); // 处理响应数据 $result = json_decode($response, true); if ($result['status'] == 1) { // 纠偏成功,输出纠偏后的数据 print_r($result['data']['corrected_points']); } else { // 纠偏失败,输出错误信息 echo $result['message']; } ``` 其中,`$key` 为高德地图开发者平台申请的 API Key,`$url` 为 API 的请求地址,`$file` 为包含 GPS 数据的 JSON 文件路径。 在示例代码中,我们首先读取 GPS 数据文件,构造 API 请求参数,并使用 cURL 发送 POST 请求。最后,解析 API 响应数据,如果纠偏成功则输出纠偏后的数据,否则输出错误信息。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值