0

我有几个形状需要设置样式并添加到 OpenLayers 3 地图中。

我从 SQL 获得的形状数据看起来像这样......

{"coordinates":[[[[-91.05450505,40.13582599899992],[-91.0535575279999,40.135820151999923],[-91.052466883,40.1358134119999],[-91.0523327989999,40.135812912999924],[-91.052166245,40.135813424999817],[-91.0510157859999,40.135816934999816], [-91.0509395239999,40.135817163999938],[-91.049898524,40.135809289999926],[-91.048985755,40.137104035999819],[-91.0483429609999,40.137688143999824],[-91.047584907,40.13776131299992],[-91.047550132,40.139484142999919],[-91.047548976,40.139541301999927],[ -91.057030214,40.139655613999814],[-91.057029888,40.139645160999819],[-91.057034944,40.139477644999936],[-91.057054502,40.13833740399982],[-91.057055873,40.138257448999831],[-91.057098826,40.135917570999929],[-91.056919183,40.135869905999826],[- 91.0556241099999,40.135850547999922],[-91.054810698,40.135832702999927],[-91.05450505,40.13582599899992]]]],"类型":"多多边形"}

OpenLayers 3 中让这个多边形形状显示在地图上然后更改范围以显示我在哪里绘制这个形状的最佳方法是什么?

4

1 回答 1

0

您的数据似乎是 GeoJSON 格式。

你可以在这里找到一个例子 http://openlayers.org/en/master/examples/geojson.html

考虑到您只有有效 geojson 的几何部分,因此您应该添加特征定义: { 'type': 'Feature', 'geometry': { 'type': 'MultiPolygon', 'coordinates': [ [[[-5e6, 6e6], [-5e6, 8e6], [-3e6, 8e6], [-3e6, 6e6]]], [[[-2e6, 6e6], [-2e6, 8e6], [0, 8e6], [0, 6e6]]], [[[1e6, 6e6], [1e6, 8e6], [3e6, 8e6], [3e6, 6e6]]] ] } }

于 2016-06-09T06:33:59.120 回答