sagulnet / 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

Events not working. #119

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
hello,

I've downloaded your code today and been playing with event. I've tried your 
code below - taken directly from the web page - I can see the marker on the 
map, when I click on it it jumps to show me the click. But, the code never gets 
as far as calling SomeMethod? Not sure why not.

I wonder if youcan firm that this works your end?

I'm building this in VS 2013 with GE 6.1.0.5001

Martin

[ComVisibleAttribute(true)]
    public class MyExternal : External
    {
        GEWebBrowser browser = null;
        dynamic pm1 = null;

        public MyExternal(GEWebBrowser browser)
            : base()
        {
            this.browser = browser;

            this.PluginReady += (o, e) =>
            {
                //create a placemark
                pm1 = KmlHelpers.CreatePlacemark(e.ApiObject, "pm1", 52, 0);

                // add the event listener to the placemark.
                // notice the callback parameter, it is an anonymous javascript function
                // that calls 'SomeMethod' with an argument 'hello'
                this.browser.AddEventListener(pm1, EventId.Click, "function(e){application.SomeMethod(e);}");
            };
        }

        /// <summary>
        /// SomeMethod, called when the placemark is clicked
        /// </summary>
        /// <param name="e">event data</param>
        public void SomeMethod(dynamic e)
        {
            // you can use native api calls on the object 
            string type = e.getType(); // KmlMouseEvent
            string targetType = e.getTarget().getType(); // KmlPlacemark
            MessageBox.Show(type, targetType);

            // Remove the event, notice we don't need to supply the custom 
            // script argument. The internal event logic does that for you.
            this.browser.RemoveEventListener(pm1, EventId.Click);
        }
    }

Original issue reported on code.google.com by mar...@oculustechnologies.nl on 24 Jun 2014 at 2:33

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