>The thing I can't figure out is, if I had the JSON data already in 
GeoJSON format, in a Javascript >variable, how do I make an OpenLayers 
layer out of it?

Script insertion?
I load a json file (which in my case is a variable structure describing 
the layer I want to load and all its properties) with:
         function injectScript(filename){
            var headID = document.getElementsByTagName("head")[0];
           curScriptTag = document.createElement('script');
           curScriptTag.type = 'text/javascript';
           curScriptTag.src = filename;
           curScriptTag.onload= scriptLoaded;
           headID.appendChild(curScriptTag);
         }
         function scriptLoaded() {
           curScriptTag.parentNode.removeChild(curScriptTag);
         }

Now the trick is that in the json file, I surround the js variable with 
a function call. eg
If my variable was: [{"layername":"mylayer", etc}] I change it to
layerLoad([{"layername":"mylayer", etc}]) and in my code I have function

function layerLoad(layerobj) {
etc
}
to process the variable.

HTH.


-- 
Phil Scadden, Senior Scientist GNS Science Ltd 764 Cumberland St, 
Private Bag 1930, Dunedin, New Zealand Ph +64 3 4799663, fax +64 3 477 5232

Notice: This email and any attachments are confidential. If received in error 
please destroy and immediately notify us. Do not copy or disclose the contents.

_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to