Mapbox加载浙江省天地图服务和数据处理

1. 加载影像服务

通过浙江省天地图官网申请所需服务,使用token获取服务数据

由于浙江省天地图使用的坐标系是 cgcs2000,需要使用 的框架对应为 @cgcs2000/mapbox-gl,通过cdn引入或npm下载

影像服务地址为:

'https://ditu.zjzwfw.gov.cn:443/services/wmts/imgmap/default/oss?service=WMTS\&request=GetTile\&version=1.0.0\&layer=imgmap\&style=default\&tilematrixSet=esritilematirx\&format=image%2Fjpgpng\&height=256\&width=256\&fullExtent=[object Object]\&tilematrix={z}\&tilerow={y}\&tilecol={x}\&token=申请的token'

影像标注地址为:

'https://ditu.zjzwfw.gov.cn:443/services/wmts/emap_lab/default/oss?service=WMTS\&request=GetTile\&version=1.0.0\&layer=imgmap\&style=default\&tilematrixSet=esritilematirx\&format=image%2Fjpgpng\&height=256\&width=256\&fullExtent=[object Object]\&tilematrix={z}\&tilerow={y}\&tilecol={x}\&token=申请的token'

其他的服务同理

2. 行政边界获取

const getData =async (name) => {

const res = await fetch('https://ditu.zjzwfw.gov.cn/ime-server/rest/xzqh_zj/division/search?withgeometry=true\&token=申请的token\&withparents=false\&fullname=' + name)

.then(resp => resp.json())

return res

}

getData('浙江省杭州市')

3. 行政边界数据处理

获取的数据为wkt 格式,需要使用gis小工具 wicket

wicket 使用cdn或npm 下载

javascript 复制代码
// 使用npm下载
import Wkt from 'wicket'

const wkt = new Wkt.Wkt()

// item.GEOMETRY 为 wkt字符串
const geometry = wkt.read(item.GEOMETRY).toJson()

4. 行政区划查询(正向、逆向)

javascript 复制代码
// 正向
const searchData =async (name) => {
  const res = await fetch('https://ditu.zjzwfw.gov.cn/ime-server/rest/xzqh_zj/division/search?callback=showresult&v=2&token=申请的token&fullname=' + name)
      .then(resp => resp.json())

  return res
}

searchData('浙江省杭州市')


// 逆向
const searchRgeo =async (lnglat:{
  lon: number,
  lat: number
}) => {
  const res = await fetch(`https://ditu.zjzwfw.gov.cn/ime-server/rest/xzqh_zj/division/rgeo?lon=${lnglat.lon}&lat=${lnglat.lat}&token=申请的token`)
      // .then(resp => resp.json())

  return res
}

  searchRgeo({
    lat: 30.25961,
    lon: 120.13026
  })
相关推荐
张元清1 天前
React useSessionStorage Hook:刷新不丢、只属于当前标签页的状态 (2026)
前端·javascript·react.js
weixin_BYSJ19871 天前
flask民族服饰饰品商城小程序---附源码37399
java·javascript·spring boot·python·小程序·django·php
xiaominlaopodaren1 天前
three.js最小地图运行时(一):视图状态
javascript·gis·three.js
Orange_sparkle1 天前
从五个 TypeScript 文件看懂 Coding Agent:一次 nano-pi 学习复盘
javascript·学习·typescript
摸鱼研究员1 天前
neverthrow,ts 中优雅的异常处理方案
前端·javascript
烬羽1 天前
求第 K 大,为什么反而要用最小堆?
javascript·数据结构·算法
jingchao19981 天前
Cannot read properties of null (reading ‘insertBefore‘)
前端·javascript·vue.js
梦醒沉醉1 天前
2、JavaScript控制流和错误处理
javascript
晓得迷路了1 天前
栗子前端技术周刊第 142 期 - DeepSeek Harness、pnpm 12 RC、crypto‑js...
前端·javascript·ai编程
Fluxart.ai1 天前
Etsy手工制品换背景,用什么AI能保留手作质感?
前端·javascript·人工智能