Snippets

Piotr Szrajber Geospatial Portal - customize the way point measurements are displayed

Created by Piotr Szrajber
/**
 * Overwrite coordinates decorations
 *
 * This example shows how to display transformed/recomputed measurements for points
 * - value is shown as a square root of the given coordinate
 * - additional text after unit is added
 * This is of course nonsense just for the purpose of demonstration
 *
 * 2017-11-24 Piotr Szrajber <piotr.szrajber@hexagongeospatial.com>
 */
Sys.Application.add_init(function() {
    var _translate_ = Intergraph.WebSolutions.Core.WebClient.Platform.Translate,
        _draw_ = Intergraph.WebSolutions.Core.WebClient.Platform.ClientScript.Draw,
        pointLabelLength = 200; // length of the label in pixels TODO: CHANGE HERE

    Intergraph.WebSolutions.Core.WebClient.Platform.ClientScript.Draw.DecorationLayer.prototype._getCoordsDecorations = function(point) {
        var texts = [],
            isGeographic = $crs.getCurrent().get_isGeographic(),
            unit = (isGeographic ? _translate_.AbbrDegrees : _translate_.AbbrMeters) + "^½", // TODO: CHANGE HERE
            latIndicator = isGeographic ? _translate_.AbbrLatitude : "",
            lonIndicator = isGeographic ? _translate_.AbbrLongitude : "",
            format = "√{0}\u0305 = {1}{2}{3}", // TODO: CHANGE HERE
            valueFormatter = function(value) {
                return Math.sqrt(value).toFixed(2); // TODO: CHANGE HERE
            };

        texts.push(String.format(format, "x", valueFormatter(point.x), unit, latIndicator)); // TODO: CHANGE HERE
        texts.push(String.format(format, "y", valueFormatter(point.y), unit, lonIndicator)); // TODO: CHANGE HERE
        return [
            new _draw_.Geometry.Label(point, null, texts[0], true, pointLabelLength),
            new _draw_.Geometry.Label(point, null, texts[1], true, pointLabelLength)
        ];
    };
});

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.