Kliver Max
Kliver Max

Reputation: 5299

How to wait function result?

I have a function:

    function createWFS(){
    //WMS
    wms_proj = new OpenLayers.Projection("EPSG:900913");    
    //WFS
    SS=new OpenLayers.Strategy.Save();
    FS=new OpenLayers.Strategy.Filter({filter:Ffilter});
    var myStyle = OpenLayers.Util.extend({},
        OpenLayers.Feature.Vector.style['default']);
    myStyle.strokeWidth = 1.5;
    myStyle.strokeColor = "#ff0000";
    myStyle.fillOpacity = 0.1;

    myVecLayer= new OpenLayers.Layer.Vector("Редактируемый участок");
    myVecLayer.projection=wms_proj;
    app.mapPanel.map.addLayers([myVecLayer]);
    myVecLayer.visibility=false;

    //Стор для зума
    zoom_tab = new GeoExt.data.FeatureStore({
        layer: myVecLayer,
        fields: [
            {name: 'id', type: 'int'},
            {name: 'filedata', type: 'String'}
        ],
        proxy: new GeoExt.data.ProtocolProxy({
            protocol: new OpenLayers.Protocol.HTTP({
                //url: "/geoserver/ows?service=WFS&request=GetFeature&typeName=mrsk:parcels_temp&srsName=EPSG:4326&outputFormat=GML2",
                url: "/geoserver/ows?service=WFS&request=GetFeature&typeName=cite:parcels_temp&srsName=EPSG:4326&outputFormat=GML2",
                format: new OpenLayers.Format.GML()
            })
        }),
        autoLoad: true
    });
    zoom_store=zoom_tab;
}

You see that this function create WFS Layer and GeoExt.FeatureStore. I dont know how long function will work.
So now i call this function and want ot wait function result before make next code. How to make this?

Upvotes: 0

Views: 196

Answers (1)

Shadow Wizard
Shadow Wizard

Reputation: 66388

Just pass it your own callback:

function createWFS(callback) {
    //WMS
    ...
    if (callback)
        callback();
}


function Main() {
    createWFS(NextStep);
}

function NextStep() {
    //stuff here
}

Upvotes: 1

Related Questions