سؤال

I have a code that was answered for me in another post which is below. However I have since ran into a new problem that I can't solve easily. I added additional LoadKML functions e.g. Function LoadKML1(), function LoadKML2(). The problem is now I need to click the killKML button to clear LoadKML1 before I can click LoadKML2. I would like to have the LoadKML1 clicked to load the KML and if clicked again LoadKML1 to run the killKML code. basically an on and off button in essence.

Any help is appreciated.

var kmlLoaded = false;

function LoadKML() {
    alert('Kill KML');
        if (kmlLoaded) {
        return
            killKML();
        }else{
            alert('Creating KML');
            var nwlink = "http://kml-samples.googlecode.com/svn/trunk/kml/NetworkLink/placemark.kml"
            createNetworkLink(nwlink);
            kmlLoaded=true;
        }
}

function killKML(source) {
    ge.getGlobe().getFeatures().removeChild(networkLink);
هل كانت مفيدة؟

المحلول

you could change your code and call the killKML() in the kmlLoaded check like this:

function LoadKML() {
    if (kmlLoaded) {
        //return
        killKML();
    }else{
        var newlink = "http://www.something.com/test.kml";
        createNetworkLink(newlink);
        kmlLoaded=true;
    }
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top