By default objects in a Layer need to be geolocated so that the renderer knows where to draw them. A hack I found involves using D3 to map svg features into vectors with a custom projection function for the renderer. It also handles listening for move/pan. see: http://bl.ocks.org/pbogden/6283017
some code from the solution reproduced here
d3.json("us-states.json", function(err, collection) {
var bounds = d3.geo.bounds(collection),
path = d3.geo.path().projection(project), // create a d3.geo.path that converts GeoJSON to SVG
vector = new OpenLayers.Layer.Vector( "states" ); // create a vector layer
// Use D3 to add the states after the vector layer has been added to the map
vector.afterAdd = function() {
var div = d3.select("#"+vector.div.id);
div.selectAll("svg").remove(); // Prepare OpenLayers vector div to be the container for D3
var svg = div.append("svg"),
g = svg.append("g");
var states = g.selectAll("path")
.data(collection.features)
.enter().append("path");
reset();
// Reposition the SVG to cover the features
function reset() {
var bottomLeft = project(bounds[0]),
topRight = project(bounds[1]);
svg .attr("width", topRight[0] - bottomLeft[0])
.attr("height",bottomLeft[1] - topRight[1])
.style("margin-left", bottomLeft[0] + "px")
.style("margin-top", topRight[1] + "px");
g .attr("transform", "translate(" + -bottomLeft[0] + "," + -topRight[1] + ")")
states.attr("d", path);
};
map.events.register("moveend", map, reset);
};
// Add the vector layer to the map
map.addLayer(vector);
// Use OpenLayers to implement a custom D3 geographic projection.
// Converts lon/lat to viewport coordinates (D3 uses 2-element arrays).
function project(x) {
var point = map.getViewPortPxFromLonLat( new OpenLayers.LonLat(x[0], x[1])
.transform("EPSG:4326", "EPSG:900913")
);
return [ point.x, point.y ];
}
});