[Users] styling for measure tool line

Bart van den Eijnden (OSGIS) bartvde at osgis.nl
Wed Oct 6 13:32:13 CEST 2010


Hi Robert,

this is an OpenLayers question, however, here is an example:

GeoServices.createMeasureStyleMap = function() {
    var measureSymbolizers = {
        "Point": {
            pointRadius: 4,
            graphicName: "square",
            fillColor: "white",
            fillOpacity: 1,
            strokeWidth: 1,
            strokeOpacity: 1,
            strokeColor: "#333333"
        },
        "Line": {
            strokeWidth: 3,
            strokeOpacity: 1,
            strokeColor: "#666666",
            strokeDashstyle: "dash"
        },
        "Polygon": {
            strokeWidth: 2,
            strokeOpacity: 1,
            strokeColor: "#666666",
            fillColor: "white",
            fillOpacity: 0.3
        }
    };
    var style = new OpenLayers.Style();
    style.addRules([
        new OpenLayers.Rule({symbolizer: measureSymbolizers})
    ]);
    return new OpenLayers.StyleMap({"default": style});
};


    MeasureLengthAction: new GeoExt.Action({
        control: new OpenLayers.Control.Measure(
            OpenLayers.Handler.Path,
            {
                eventListeners: {
                    'measure': GeoServices.handleMeasure,
                    'measurepartial': GeoServices.handleMeasure,
                    'deactivate': GeoServices.clearMeasure
                },
                handlerOptions: {
                    style: 'default',
                    layerOptions: {
                        styleMap: GeoServices.createMeasureStyleMap()
                    },
                    persist: true
                },
                geodesic: true,
                displayUnits: 'km'
            }
        ),
        map: GeoServices.getApplication().map,
        toggleGroup: 'map',
        actionGroup: OpenLayers.i18n('NavigationTitle'),
        itemId: 'MEASURELENGTH',
        iconCls: 'measurelength',
        tooltip: {
            title: OpenLayers.i18n('NavigationMeasureTitle'),
            text: OpenLayers.i18n('NavigationMeasureTooltip')
        }
    }),

Best regards,
Bart

> Hi,
>
> I have managed to successfully create my line/area measuring tools. I
> would like
> to now style the vectors which are drawn on the map when measuring.
> How can I alter the line style from the default vecotr orange to something
> nicer?
>
> Thanks,
>
> Robert Buckley
>
>
> _______________________________________________
> Users mailing list
> Users at geoext.org
> http://www.geoext.org/cgi-bin/mailman/listinfo/users
>




More information about the Users mailing list