Skip to content

Yandex Maps

Yandex Maps 是 Yandex 的地图和导航应用。Protocol Launcher 允许你生成 Yandex Maps URL scheme 链接和网页链接。

使用方式

有两种使用此库的方式:

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

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

选择安装方式

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

注意事项

此模块只封装 Yandex 官方文档列出的 yandexmaps:// 移动 App 链接、Yandex Maps 支持的 Android geo: 示例能力,以及 https://yandex.ru/maps/ 网页链接。

Yandex 文档将 llpt、“这里是什么?”和全景图坐标写作 longitude,latitude。路线 rtext 另行记录为 latitude,longitude~latitude,longitude,Android geo: 示例使用 latitude,longitude。移动 App 路线类型仅限 automtpd;网页路线 helper 还支持 Web 文档中的 bc 自行车路线类型。

移动 App

打开地图

On-Demand
ts
import { openMap } from 'protocol-launcher/yandex-maps'

const url = openMap({
  ll: '37.619902,55.753716',
  z: 11,
  l: ['map', 'trf'],
})

添加标记点

On-Demand
ts
import { showPoint } from 'protocol-launcher/yandex-maps'

const url = showPoint({
  pt: '30.335429,59.944869',
  z: 18,
  l: 'map',
})

查找对象

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

const url = search({
  ll: '30.310182,59.951059',
  z: 16,
  text: 'cafe with wi-fi',
})

打开组织卡片

On-Demand
ts
import { openOrganizationCard } from 'protocol-launcher/yandex-maps'

const url = openOrganizationCard({
  oid: 1184371713,
})

显示“这里是什么?”

On-Demand
ts
import { showWhatsHere } from 'protocol-launcher/yandex-maps'

const url = showWhatsHere({
  point: '37.444075,55.776788',
  zoom: 17,
})

规划路线

On-Demand
ts
import { route } from 'protocol-launcher/yandex-maps'

const url = route({
  rtext: '59.967870,30.242658~59.898495,30.299559',
  rtt: 'mt',
})

显示全景图

On-Demand
ts
import { panorama } from 'protocol-launcher/yandex-maps'

const url = panorama({
  point: '37.444075,55.776788',
  direction: '228.970000,6.060547',
  span: '130.000000,71.919192',
})

Android Geo Scheme

On-Demand
ts
import { androidGeo } from 'protocol-launcher/yandex-maps'

const url = androidGeo({
  coordinates: '47.6,-122.3',
  z: 11,
})

Web

打开网页地图

On-Demand
ts
import { webMap } from 'protocol-launcher/yandex-maps'

const url = webMap({
  ll: '30.310182,59.951059',
  z: 12,
  l: 'map',
})

添加网页标记点

On-Demand
ts
import { webShowPoint } from 'protocol-launcher/yandex-maps'

const url = webShowPoint({
  pt: '30.335429,59.944869',
  z: 18,
  l: 'map',
})

添加多个网页标记点

On-Demand
ts
import { webShowPoints } from 'protocol-launcher/yandex-maps'

const url = webShowPoints({
  ll: '30.310182,59.951059',
  pt: '30.335429,59.944869~30.34127,59.89173',
  z: 12,
  l: 'map',
})

查找网页对象

On-Demand
ts
import { webSearch } from 'protocol-launcher/yandex-maps'

const url = webSearch({
  ll: '30.310182,59.951059',
  z: 16,
  text: 'cafe with wi-fi',
})

打开网页组织卡片

On-Demand
ts
import { webOpenOrganizationCard } from 'protocol-launcher/yandex-maps'

const url = webOpenOrganizationCard({
  oid: 1184371713,
})

显示网页“这里是什么?”

On-Demand
ts
import { webShowWhatsHere } from 'protocol-launcher/yandex-maps'

const url = webShowWhatsHere({
  point: '37.444075,55.776788',
  zoom: 17,
})

规划网页路线

On-Demand
ts
import { webRoute } from 'protocol-launcher/yandex-maps'

const url = webRoute({
  rtext: '59.967870,30.242658~59.898495,30.299559',
  rtt: 'bc',
})

显示网页全景图

On-Demand
ts
import { webPanorama } from 'protocol-launcher/yandex-maps'

const url = webPanorama({
  point: '37.444075,55.776788',
  direction: '228.970000,6.060547',
  span: '130.000000,71.919192',
})

官方文档