What is wrong with my geoJSON?

297 views
Skip to first unread message

mohamed...@gmail.com

unread,
Sep 20, 2014, 7:25:38 AM9/20/14
to cesiu...@googlegroups.com
The geoJSON sandcastle examples runs perfectly with me, but when I use my own geoJSON file as a data source nothing appear. Please help:

Below is my geoJSON data source:

{ "type": "Feature", "properties": { "OBJECTID": 20, "ENGID": "40RBN5319301351"}, "geometry": { "type": "Polygon", "coordinates": [ [ [ 54.566124539478878, 24.406021338476325 ], [ 54.566148107752099, 24.406028017955055 ], [ 54.566115732828465, 24.406123836089698 ], [ 54.566235456768659, 24.406157760188982 ], [ 54.566255574031182, 24.406098193520144 ], [ 54.566281975778445, 24.406105667739457 ], [ 54.566279060022957, 24.406114304250391 ], [ 54.566329951512451, 24.406128725476261 ], [ 54.566371950924683, 24.406004421274567 ], [ 54.566292775469798, 24.405981990105861 ], [ 54.566286944486251, 24.405999236057994 ], [ 54.566270925041493, 24.405994699916651 ], [ 54.566268584486721, 24.406001612608108 ], [ 54.566239349486047, 24.405993334604545 ], [ 54.566241680361216, 24.405986412731547 ], [ 54.566182308651392, 24.405969589467993 ], [ 54.566175004474289, 24.405991180502262 ], [ 54.566138240189531, 24.405980768499898 ], [ 54.566124539478878, 24.406021338476325 ] ] ] } }


and below is the source code:

//Create the viewer
var viewer = new Cesium.Viewer('cesiumContainer');
Cesium.viewerEntityMixin(viewer);

var dataSource = new Cesium.GeoJsonDataSource();
viewer.dataSources.add(dataSource);
dataSource.loadUrl('../../SampleData/bldgs.geojson');

mohamed...@gmail.com

unread,
Sep 21, 2014, 12:27:43 AM9/21/14
to cesiu...@googlegroups.com, mohamed...@gmail.com
Even the original geojson example is not working when I run it locally.

Any idea?

mohamed...@gmail.com

unread,
Sep 21, 2014, 6:34:44 AM9/21/14
to cesiu...@googlegroups.com, mohamed...@gmail.com
By the way, I am using IIS as a web server, and following is the error I got when running the application using Chrom:


XMLHttpRequest cannot load http://hqtpssdd0082d/Cesium/Apps/Sandcastle/ne_10m_us_states.topojson. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:52956' is therefore not allowed access. GeoJSON.html:1

Scott Hunter

unread,
Sep 23, 2014, 10:55:14 AM9/23/14
to cesiu...@googlegroups.com
IIS by default does not serve file extensions that it doesn't recognize.  This includes .geojson and .topojson files.  You have to configure it to tell it the correct MIME type to use for those extensions.  http://stackoverflow.com/questions/8158193/how-to-allow-download-of-json-file-with-asp-net

Also, if you want to load files from a different server, you will also need to enable CORS headers on the server hosting the data file.  http://enable-cors.org/server_iis7.html



On Sun, Sep 21, 2014 at 6:34 AM, <mohamed...@gmail.com> wrote:
By the way, I am using IIS as a web server, and following is the error I got when running the application using Chrom:


XMLHttpRequest cannot load http://hqtpssdd0082d/Cesium/Apps/Sandcastle/ne_10m_us_states.topojson. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:52956' is therefore not allowed access. GeoJSON.html:1

--
You received this message because you are subscribed to the Google Groups "cesium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cesium-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

mohamed...@gmail.com

unread,
Sep 24, 2014, 2:44:12 AM9/24/14
to cesiu...@googlegroups.com
Many thanks Scott Hunter, it is working now.
Reply all
Reply to author
Forward
0 new messages