Skip to content

Guru Maps

Guru Maps 是一款离线地图与导航应用。Protocol Launcher 允许你生成 Guru Maps URL Scheme 链接。

使用方式

有两种使用此库的方式:

  • 按需导入(On-Demand):从子路径导入支持 tree-shaking,保持较小的打包体积。
  • 完整导入(Full Import):从根包导入更方便,但会包含所有应用模块。

生产构建建议选择按需导入;快速脚本或演示可以使用完整导入。

选择安装方式

按需加载
推荐使用。生产环境优化。
全量导入
使用便捷。适合快速脚本。

注意事项

此模块只封装 Guru Maps 手册中记录的 guru:guru:// API。geo: helper 刻意保持很窄:官方页面只展示了用于显示位置的 geo:lat,lon,并说明它不支持 back_url

backUrl 会映射到 Guru Maps 文档中的 back_url 参数。

打开 Guru Maps

On-Demand
ts
import { open } from 'protocol-launcher/guru-maps'

const url = open()

使用返回 URL 打开

On-Demand
ts
import { open } from 'protocol-launcher/guru-maps'

const url = open({
  backUrl: 'https://gurumaps.app',
})

导入文件

On-Demand
ts
import { importFile } from 'protocol-launcher/guru-maps'

const url = importFile({
  url: 'https://gurumaps.app/example/feature_collection.geojson',
})

搜索

On-Demand
ts
import { search } from 'protocol-launcher/guru-maps'

const url = search({
  q: 'Wybrzeże Kościuszkowskie 20 Warszawa',
  coord: '52.2297,21.0122',
})

导航

On-Demand
ts
import { navigate } from 'protocol-launcher/guru-maps'

const url = navigate({
  start: '52.2297,21.0122',
  finish: '52.2397,21.0222',
  via: '52.2347,21.0172',
  mode: 'bicycle',
  startNavigation: true,
})

记录轨迹

On-Demand
ts
import { recordTrack } from 'protocol-launcher/guru-maps'

const url = recordTrack({
  action: 'start',
})

保存标记

On-Demand
ts
import { saveMarker } from 'protocol-launcher/guru-maps'

const url = saveMarker({
  name: 'MyMarker',
  coord: '52.2297,21.0122',
})

显示地点

On-Demand
ts
import { showPlace } from 'protocol-launcher/guru-maps'

const url = showPlace({
  coord: '52.2297,21.0122',
  zoom: 17,
})

Geo

On-Demand
ts
import { geo } from 'protocol-launcher/guru-maps'

const url = geo({
  coord: '52.2297,21.0122',
})

官方文档