Friday, 6 May 2016

geojson - Geoserver WFS GetFeature doesn't work - "SyntaxError: missing ; before statement"



I'm trying to use GeoServer WFS JSON for creating a vector layer (instead of using WMS) because this is a layer I redraw every 20 seconds.


This is the code I use :


function getJSON() {


var geoJsonUrl = "http://localhost:8080/geoserver/test/ows?service=WFS&version=1.1.0&request=GetFeature&typeName=test:Coords&srsName=EPSG:4326&format=text/javascript&outputFormat=json&format_options=callback:loadGeoJson";

$j.ajax({
url: geoJsonUrl,
dataType: 'jsonp'
});
}

function loadGeoJson(data) {
console.log('success');

}

The JSON from the request is :


{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"id": "DIView.fid-25487b92_142a9c99a7e_-5722",
"geometry": {

"type": "Point",
"coordinates": [
34.8923,
32.1893
]
},
"geometry_name": "DeviceLocation",
"properties": {
"Id": 1,
"DeviceSerial": "046009117212",

"DateTime": "2013-12-03T12:20:48.080Z",
"Spd": "4.72175 ",
"Brn": "143.3 ",
"Alt": "91.6 ",
"DeviceName": "12",
"DeviceReversedName": "21",
"DeviceBattery": 3.71
}
},
{

"type": "Feature",
"id": "DIView.fid-25487b92_142a9c99a7e_-5721",
"geometry": {
"type": "Point",
"coordinates": [
34.8025,
31.2813
]
},
"geometry_name": "DeviceLocation",

"properties": {
"Id": 2,
"DeviceSerial": "046009117224",
"DateTime": "2013-12-03T12:41:12.313Z",
"Spd": "0 ",
"Brn": "136 ",
"Alt": "349 ",
"DeviceName": "24",
"DeviceReversedName": "42",
"DeviceBattery": 0.29

}
},
{
"type": "Feature",
"id": "DIView.fid-25487b92_142a9c99a7e_-5720",
"geometry": {
"type": "Point",
"coordinates": [
34.8026,
31.2812

]
},
"geometry_name": "DeviceLocation",
"properties": {
"Id": 3,
"DeviceSerial": "047180050069",
"DateTime": "2013-12-03T12:41:14.140Z",
"Spd": "0.690988 ",
"Brn": "161.8 ",
"Alt": "340.2 ",

"DeviceName": "4",
"DeviceReversedName": "4",
"DeviceBattery": 3.65
}
}
],
"crs": {
"type": "EPSG",
"properties": {
"code": "4326"

}
}
}

and I get error in Firebug :


enter image description here


Any idea ?!




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...