Get coordinates tool

In this example, we create an instant tool which will draw a point feature on a desired location and display the location's coordinates.

The code:

// create the tool
tool = new giscloud.ui.Toolbar.Tool("pointTool", {

        // instant tools don' stay activated
        instant: true,

        styles: {
            caption: "Get coordinates",
            showCaption: true,
            cssClass: "mytool",
            active: "mytool-active",
            hover: "mytool-hover"
        },

        actions: {

            // since this is a instant tool, only the activation action is needed
            activation: function (viewer) {

                // clear previously added graphic features
                viewer.graphic.clear();

                // start drawing
                viewer.graphic.draw("point",
                    function (point) {

                        // when done, show coordinates
                        showCoordinates(point.geometry());

                    }
                );

            }
        }
    }
);