Reputation: 1518
OL3 and MVC5. I have an mvc controller that returns wkt polygon strings from oracle. I want to render these in open layers but i can't find out what the format should look like to make ol happy.
var tAVectorSource = new ol.source.Vector({
format: new ol.format.WKT(),
url: function (extent) {
return '/MyController/Map/MyWKTPolygons';
},
strategy: ol.loadingstrategy.bbox
});
var tAVectors = new ol.layer.Vector({
source: tAreaVectorSource,
style: tAStyle
});
my controller is returning this:
{"TAId":4,"PId":21,"TType":1,"TShape":"POLYGON ((-1.2695884640625E7 4445506.375, -1.21430920625E7 4451637.25, -1.2152876E7 5012485.703125, -1.2373014640625E7 5006005.84375, -1.2373014640625E7 5162735.015625, -1.2695884640625E7 5156153.28125, -1.2695884640625E7 4445506.375))","TAcres":0}
Right now i get
Unexpected character: {
before that i was testing returning several features and the Unexpected character was the [ brace defining the list. What would OL like and where can i find the spec or an example to make it satisfied?
Upvotes: 0
Views: 572
Reputation: 6041
Your controller is returning JSON which contains a WKT string as attribute. When using ol.format.WKT
your controller should only return the WKT string (POLYGON (...)
).
You might want to use GeoJSON if you are also interested in getting the properties of your features.
Upvotes: 1