[Users] Measure Length and Area UX Tools Give Error

IT Intern itintern12 at gmail.com
Tue Dec 21 17:01:40 CET 2010


Dear GeoExt Users,

I have a map using the ExtJS and GeoExtJS libraries which also incorporate
the Measure Length and Area UX tools.  Things are going pretty good, except
that when these measuring tools are used, they create extra nodes in my
tree.  The nodes that get created are OpenLayers.Handler.Polygon for the
Area tool and OpenLayers.Handler.Path for the length tool.  Not only are
these unwanted nodes for me, but these nodes also seem to have some impact
on my nodes iconCls, as the icon I have set for them change back to default
when these new nodes are added.  I am adding some code here which I think
may be relevant, but if it is not enough to explain what I am doing, I can
gladly provide more :)

 <body onload="">

        <script src="./ext-3.3.0/adapter/ext/ext-base.js"
type="text/javascript"></script>
        <script src="./ext-3.3.0/ext-all.js"
type="text/javascript"></script>
        <script src="./GeoExt/lib/GeoExt.js"
type="text/javascript"></script>
        <script src="./GeoExt/ux/widgets/MousePositionItem.js"
type="text/javascript"></script>
        <script src="./GeoExt/lib/GeoExt.ux/Measure.js"
type="text/javascript"></script>
        <script src="./GeoExt/lib/GeoExt.ux/MeasureArea.js"
type="text/javascript"></script>
        <script src="./GeoExt/lib/GeoExt.ux/MeasureLength.js"
type="text/javascript"></script>

<script type="text/javascript">

        //Default blank image needed for some ExtJS widgets/if no image is
found...
        Ext.BLANK_IMAGE_URL = "./ext-3.2.1/resources/images/default/s.gif";

        var layerRoot;

        Ext.onReady(function() {

            // required for tooltips
            Ext.QuickTips.init();

           //Map properties
            var options = {
                    controls: [new OpenLayers.Control.Navigation()],
//Needed to use GeoExt controls such as the zoomslider
                    maxExtent: new OpenLayers.Bounds(-20037508.34,
-20037508.34, 20037508.34, 20037508.34),
                    units: 'm',
                    allOverlays: false //Do not display all layers on load
            }

            var map = new OpenLayers.Map(options);

           //Control for measuring the length between two points
            var measureLength = new GeoExt.ux.MeasureLength({
                map: map,
                    controlOptions: {
                        geodesic: true
                     },
                    toggleGroup: 'tools'
            });

            //Control for measuring the area between three or more points
            var measureArea = new GeoExt.ux.MeasureArea({
                map: map,
                decimals: 0,
                toggleGroup: 'tools'
            });

            var mapPanel = new GeoExt.MapPanel({
                title: "Map",
                map: map,
                id: 'mapPanel',
                layerStore: map.layers,
                //Set the map to be centered at specified
longitude/latitude, transform our layers (SRID=4326) to display properly on
Google
                //base layers (SRID=900913)
                center: new OpenLayers.LonLat(93.9, 29.53).transform(new
OpenLayers.Projection("EPSG:4326"), new
OpenLayers.Projection("EPSG:900913")),
                zoom: 8,
                region: "center",
                tbar: [measureLength, '-', measureArea, '-'],
                bbar: [
                {
                    xtype: "label",
                    text: "Scale = 1 : "
                }

                ],
                items: [{
                    xtype: "gx_zoomslider",
                    vertical: true,
                    height: 300,
                    aggressive: true,
                    x: 10,
                    y: 20,
                    plugins: new GeoExt.ZoomSliderTip()
                }]
            });

//Here is a function I made to change the node icon of the leaf nodes
function childrenIcons(parent, layerRoot){
    for(var c = 0; c <
layerRoot.getOwnerTree().getNodeById(parent.id).childNodes.length;
c++){
        layerRoot.getOwnerTree().getNodeById(parent.id).childNodes[c].eachChild(function(node)
{
            if (node.isLeaf()) {
                node.setIconCls(node.text);
            }//end if
        });//end eachChild
    }//end for
}//end childrenIcons

I appreciate your time and consideration concerning this matter.

Thank you,

elshae
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20101221/1ad9085e/attachment.htm 


More information about the Users mailing list