0

I have several shapes that I need to style and add to an OpenLayers 3 map.

The shape data I have from SQL looks like this...

{"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]]]],"type":"MultiPolygon"}

Whats the best way in OpenLayers 3 to get this polygon shape to show up on the map and then change the extent to show where I have drawn this shape?

ahocevar
  • 5,448
  • 15
  • 29
Funn_Bobby
  • 647
  • 1
  • 20
  • 57

1 Answers1

0

Your data seems to be in GeoJSON format.

You can find an example here http://openlayers.org/en/master/examples/geojson.html

Consider that you have only the geometry part of a valid geojson, so you should add the feature definition: { '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]]] ] } }

fradal83
  • 2,002
  • 1
  • 10
  • 9