绘制点标记 最后更新时间: 2025年05月26日
点标记用来在地图上标记任何位置,例如用户位置、车辆位置、店铺位置等一切带有位置属性的事物。
awk_map_point_overlay_t pointOverlay;
// 调用初始化接口(填充部分默认值)
awk_map_init_point_overlay(&pointOverlay);
// 经纬度坐标,需要传入GCJ02坐标系的坐标
pointOverlay.position.lon = 116.473362;
pointOverlay.position.lat = 39.995273;
// 纹理锚点和缩放比例
pointOverlay.normal_marker.icon_texture.scale = 0.8f;
pointOverlay.normal_marker.icon_texture.anchor_x = 0.5f;
pointOverlay.normal_marker.icon_texture.anchor_y = 0.5f;
// 创建纹理
awk_map_texture_data_t texture_data;
memset(&texture_data, 0, sizeof(awk_map_texture_data_t));
// 对图片进行解码,解码后的位图数据、位图宽高等信息,设置到texture_data中
loadTexture("WatchEngine.bundle/pin_start.png", &texture_data);
// 纹理添加到SDK中,返回唯一的纹理id,后续需要手动调用awk_map_remove_texture(),并传入这个纹理id作为参数,来释放纹理内存
int32_t texture_id = awk_map_add_texture(&texture_data);
// 指定覆盖物使用这个纹理
pointOverlay.normal_marker.icon_texture.texture_id = texture_id;
// 添加这个覆盖物到SDK中进行绘制
awk_map_add_overlay((uint32_t)mapId, (awk_map_base_overlay_t *)&pointOverlay);
