erl*_*man 6 java android geojson mapbox mapbox-android
GeoJson 功能如下所示:
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [
43.59375,
59.17592824927136
]
}
}
Run Code Online (Sandbox Code Playgroud)
在Mapbox使用 Java/JVM 时,我们可以构建这样的特性:
val testFeature = Feature.fromGeometry(Point.fromLngLat(2.0,3.0))
Run Code Online (Sandbox Code Playgroud)
但我似乎没有找到从特征中获取坐标/点的方法。
有一个Feature#getGeometry()但我无法从中获取坐标,因为这只是 GeoJson 界面本身的一个糖。
我刚刚发现每个特征公开了.geometry()我们可以转换为任何类型(点、线、多边形、多点等)的方法。从这里我们可以得到两种 Point 或 List<Point>。
例子 :
val position1 = feature1.geometry() as Point
val longitude = position1.longitude()
val area1 = feature2.geometry() as MultiPoint
val firstPointLatitude = area1.coordinates()!![0].latitude()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1590 次 |
| 最近记录: |