标题:Qt/C++地图感兴趣点搜索/区域搜索/周边搜索/拿到搜索结果
作者:liudianwu
日期:2025-09-03 07:34
内容:
## 一、前言说明
地图中的感兴趣点(Points of Interest, POI)是指地图上标记的特定地点或位置,这些地点通常对用户有某种意义或价值。POI 是地图数据的重要组成部分,帮助用户快速找到他们需要的地点或服务。常见的感兴趣点有商场、超市、银行、公交站、停车场、景点、酒店、电影院等。地图服务除了路线规划导航外,最常见的第二大需求就是查找感兴趣点的位置,方便直接开车或者步行过去。
各大地图厂商提供的感兴趣点搜索,也都是在线联网才能使用的,通过查询的api接口,返回对应的结果,一般结果信息中会包含具体的经纬度信息和具体地址名称等,搜索的方式默认一般是圆形搜索,也就是按照中心点对应的半径范围,也可以划定一个方形区域进行搜索,为了更加直观的标识搜索结果,会在显示兴趣点后绘制对应的形状比如圆形,圈起来,看起来就是自己要找的范围内的兴趣点。
## 二、效果图
## 三、相关代码
```cpp
#include "frmmapdemosearch.h"
#include "ui_frmmapdemosearch.h"
#include "qthelper.h"
#include "maphelper.h"
#include "maputil.h"
frmMapDemoSearch::frmMapDemoSearch(QWidget *parent) : QWidget(parent), ui(new Ui::frmMapDemoSearch)
{
ui->setupUi(this);
this->initForm();
}
frmMapDemoSearch::~frmMapDemoSearch()
{
delete ui;
}
void frmMapDemoSearch::receiveDataFromJs(const QString &type, const QVariant &data)
{
//不可见不用继续/说明不是本界面的操作触发的
if (!this->isVisible()) {
return;
}
QString result = data.toString();
if (type == "click") {
QString point = MapHelper::getLngLat2(result, 5);
if (ui->ckStart->isChecked()) {
ui->txtStart->setText(point);
} else if (ui ..