Dingshao / winforms-geplugin-control-library

Automatically exported from code.google.com/p/winforms-geplugin-control-library
GNU General Public License v3.0
0 stars 0 forks source link

CreateHtmlStringBalloon with CSS #113

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,

I'm trying to show a placemark html balloon with a bit of css added to it. Do 
to 'Content scrubbing' I'm going about it this way:

What steps will reproduce the problem?
in the geWb_kmlEvent:
e.ApiObject.preventDefault();

KmlHelpers.CreateHtmlStringBalloon(_ge, html: html, feature: kmlFeature, 
setBalloon: false);

GEHelpers.OpenFeatureBalloon(_ge, kmlFeature, true, setBalloon: true);

What is the expected output? What do you see instead?
It works the first time a placemark is clicked. The second time the balloon is 
empty.

Is there another way to do this?

What version of the product are you using? On what operating system?
r544, win7.

Regards,
Tkm

Please provide any additional information below.

Original issue reported on code.google.com by tho...@gmail.com on 4 Sep 2013 at 4:19

GoogleCodeExporter commented 8 years ago
Hi,

I think the issue is that you are possibly resetting the balloon, or else are 
reattaching to a feature and clearing its contents.

Also, you don't need the call to OpenFeatureBallon, CreateHtmlStringBalloon 
will open automatically if you remove the setBalloon parameter as it defaults 
to True.

{{{
KmlHelpers.CreateHtmlStringBalloon(_ge, html: html, feature: kmlFeature);
}}}

If that doesn't work for you then could you post a full example that shows the 
problem more clearly?

Thanks.

Original comment by fraser.c...@gmail.com on 5 Sep 2013 at 1:57

GoogleCodeExporter commented 8 years ago
Hi again. Thanks for the reply.

I was calling both CreateHtmlStringBalloon and OpenFeatureBallon as I couldn't 
make CreateHtmlStringBalloon work on its own. The balloon is shown, but all 
styling is scrubbed. Sorry for not being clear on that. 

I've done some more testing, but still cant get CreateHtmlStringBalloon() to 
work as expected. However, I've managed to get OpenFeatureBallon to work which 
means that I'm probably resetting the features balloon in my other project. I 
posted the code below.
Thanks.
private dynamic _ge = null;
        int pmCounter = 0;

        public Form1()
        {
            InitializeComponent();

            geWebBrowser1.LoadEmbeddedPlugin();

            geWebBrowser1.PluginReady += new EventHandler<GEEventArgs>(geWebBrowser1_PluginReady);
            geWebBrowser1.KmlEvent += new EventHandler<GEEventArgs>(geWebBrowser1_KmlEvent);
        }

        void geWebBrowser1_KmlEvent(object sender, GEEventArgs e)
        {
            e.ApiObject.preventDefault();
            dynamic feature = e.ApiObject.getTarget();
            /*Can't get CreateHtmlStringBalloon() to work
             * Coordinate c = new Coordinate(feature);
            KmlHelpers.CreateHtmlStringBalloon(_ge, html: HTMLHelper.CreateHTMLText(c), feature: feature);*/

            GEHelpers.OpenFeatureBalloon(_ge, feature, true, setBalloon: true);
        }

        void geWebBrowser1_PluginReady(object sender, GEEventArgs e)
        {
            _ge = e.ApiObject;

            this.geWebBrowser1.ScriptError += (o, ea) =>
            {
                MessageBox.Show(ea.Message + ": " + ea.Data, "Script Error");
            };

            //Add Control(s) to webbrowser
            this.kmlTreeView1.SetBrowserInstance(this.geWebBrowser1);

            //Move camera to a default lookat
            KmlHelpers.CreateLookAt(_ge, 56, 12, altitude: 45000);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            var point = GEHelpers.GetCurrentViewAsPoint(_ge);
            Coordinate coord = new Coordinate(point);

            dynamic pm = KmlHelpers.CreatePlacemark(_ge,
                            id: "PM " + pmCounter++,
                            latitude: coord.Latitude,
                            longitude: coord.Longitude,
                            name: "Test " + pmCounter,
                            description: HTMLHelper.CreateHTMLText(),
                            addFeature: true);

            geWebBrowser1.AddEventListener(pm, EventId.Click);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            dynamic feature = _ge.getFeatures().getChildNodes().item(0);
            //dynamic feature = GEHelpers.GetElementById(_ge, "PM 1");
            GEHelpers.OpenFeatureBalloon(_ge, feature, true, setBalloon: true); 
        }

Original comment by tho...@gmail.com on 5 Sep 2013 at 7:09

Attachments:

GoogleCodeExporter commented 8 years ago
No further development now that the Earth API is depreciated. 

Original comment by fraser.c...@gmail.com on 17 Dec 2014 at 3:20