[OpenLayers-Users] building the right type of object

Leigh Holcombe lholcombe at triple-bypass.net
Mon Mar 7 17:43:30 EST 2011


Greetings,

I have a layer constructed from a GeoJSON file, using the following code:
var trail1 = new OpenLayers.Layer.Vector("Kaau Crater", {strategies: [new OpenLayers.Strategy.Fixed()], protocol: new OpenLayers.Protocol.HTTP({url: "kaaucrater-rb.json", format: new OpenLayers.Format.GeoJSON()}), styleMap: styles, projection: utm4n});

What I'd like to do is get the bounds or centerpoint of the GeoJSON file automatically, perhaps by using something like getBounds or getCenterLonLat, but my newb mind is discovering that I can't perform these operations on the layer object I have created.  I suspect I need to also create a geometry layer from the GeoJSON file, but I am not sure how to do that.  Can anyone provide any direction?

Thanks,
Leigh Holcombe


More information about the Users mailing list