🎯
TypeScript 优先
提供完整的类型安全,支持泛型约束和类型守卫,让你的 GIS 开发更加可靠。
import {
Point,
Feature,
createFeature,
calculateDistance
} from 'geo-types-cz'
// 创建点几何
const point: Point = {
type: 'Point',
coordinates: [116.3974, 39.9093] // 北京天安门
}
// 创建要素
const feature = createFeature(point, {
name: '天安门',
city: '北京'
})
// 计算两点间距离
const distance = calculateDistance(
[116.3974, 39.9093], // 天安门
[121.4737, 31.2304] // 上海外滩
)
console.log(`距离: ${Math.round(distance / 1000)}公里`)
完整的 TypeScript 类型定义让你在编写 GIS 应用时享受智能提示和类型检查,大大提高开发效率。
严格的类型约束帮助你在编译时发现潜在问题,避免运行时错误。
不仅提供标准的 GeoJSON 类型,还扩展了样式、图层、查询等实用功能。
特别针对中国用户优化,支持常用的中国坐标系和完整的中文文档。
npm install geo-types-cz