Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm having trouble creating an OpenLayers Vector layer with GeoJSON data in an MVC 4 application.

The GET request for my json file always comes back with a 404.3 error - page cannot be served because of the extension configuration.

I've followed every OpenLayers example creating the GeoJSON layer just as they have but I can't get mine to display. I've followed the steps in this post Trouble Displaying GeoJSON file in OpenLayers and everything besides the GeoJSON layer works great.

So in my OpenLayers.aspx page I have the following code to initialize my vector layer.

var vector = new OpenLayers.Layer.Vector("GeoJSON", {
            projection: new OpenLayers.Projection("EPSG:900913"),
            strategies: [new OpenLayers.Strategy.Fixed()],
            protocol: new OpenLayers.Protocol.HTTP({
                url: "<%:this.Url.Content("~/Content/Delta_Parcels_2008.json") %>",
                format: new OpenLayers.Format.GeoJSON({
                    internalProjection: new OpenLayers.Projection("EPSG:900913"),
                    externalProjection: new OpenLayers.Projection("EPSG:4326")
                })
            }),
            styleMap: vector_style_map
        });

any suggestions would be much appreciated. thanks.

share|improve this question
    
Can you get more details about the 404 error? –  steko Mar 18 '13 at 23:14

1 Answer 1

up vote 0 down vote accepted

IIS and IIS Express do not have the mime type for "json" by default. You need to add the mime type to your web server so it knows to server the JSON file. If you are using the built in web server (Cassini) then it does not have support and you will need to switch.

Here is how you do it:

IIS 7: http://www.uipress.com/add-json-handler-support-in-iis-7/#.UUds21eRfQM

IIS Express: http://michaellhayden.blogspot.com/2012/07/add-json-mime-type-to-iis-express.html

You can also do it in your web.config: http://stackoverflow.com/questions/5924647/setting-mime-types-using-the-asp-net-development-server

share|improve this answer
    
excellent, that did the trick. No longer getting the 404 error, now to just figure out why it isn't displaying I'm guessing the projection is off. Thanks again. –  user501211 Mar 18 '13 at 20:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.