[GIS] Trouble with GeoJSON in HTTP GET Request

formatgeojsonopenlayers-2

I using a Vector Layer with the HTTP protocol to request GeoJSON from my web server, and am trying to get this GeoJSON to display on my map. The GET request appears to be working correctly, as I can see the example JSON I requested in Firebug. However, I am getting an error telling me that "this.format is null Openlayers.js (line 1186)". Unfortunately, the OpenLayers.js file is essentially unreadable so I am having a hard time figuring out what my problem might be.

I set the format for the Vector Layer to GeoJSON. My code for the layer is below:

var newLayer = new OpenLayers.Layer.Vector("Filtered by Zoom Level", {
                        strategies: [new OpenLayers.Strategy.BBOX(), 
                                    refresh,
                                    ],

                        protocol: new OpenLayers.Protocol.HTTP({
                            url: "http://server:8080/test-webapp/servlet",
                        }),

                        filter: filter,

                        styleMap: styleMap,
                        format: new OpenLayers.Format.GeoJSON({
                            externalProjection: new OpenLayers.Projection("EPSG:4326"),
                            internalProject: new OpenLayers.Projection("EPSG:900913")
                        })

                    });

Does anybody have any ideas as to what the issue might be?

Thanks,

-Rob

Best Answer

I edited a GeoJSON map of my own to match your loading strategy. The map also failed to load for me. I got rid of the "refresh" command and the map loaded as normal. I'd try that.

So:

var newLayer = new OpenLayers.Layer.Vector("Filtered by Zoom Level", {
                    strategies: [new OpenLayers.Strategy.BBOX()],

                    protocol: new OpenLayers.Protocol.HTTP({
                        url: "http://server:8080/test-webapp/servlet",
                    }),

                    filter: filter,

                    styleMap: styleMap,
                    format: new OpenLayers.Format.GeoJSON({
                        externalProjection: new OpenLayers.Projection("EPSG:4326"),
                        internalProject: new OpenLayers.Projection("EPSG:900913")
                    })

                });