[fusion-commits] r2732 - in trunk: text widgets widgets/CoordinateTracker widgets/widgetinfo

svn_fusion at osgeo.org svn_fusion at osgeo.org
Wed Jun 5 06:09:09 PDT 2013


Author: jng
Date: 2013-06-05 06:09:09 -0700 (Wed, 05 Jun 2013)
New Revision: 2732

Added:
   trunk/widgets/CoordinateTracker.js
   trunk/widgets/CoordinateTracker/
   trunk/widgets/CoordinateTracker/CoordinateTracker.css
   trunk/widgets/CoordinateTracker/CoordinateTracker.php
   trunk/widgets/widgetinfo/coordinatetracker.xml
Modified:
   trunk/text/en
Log:
#568: Implement the Coordinate Tracker widget. Still need an icon for this.

Modified: trunk/text/en
===================================================================
--- trunk/text/en	2013-06-05 06:31:28 UTC (rev 2731)
+++ trunk/text/en	2013-06-05 13:09:09 UTC (rev 2732)
@@ -464,3 +464,6 @@
 QUICKPLOT_PREVIEW_ERROR         = The application resources required to generate the plot exceed the settings defined by the administrator
 QUICKPLOT_RESOLUTION_WARNING    = The current settings exceed the map resolution. Zooming out or increasing the scaling will help create a more legible plot
 QUICKPLOT_SCALE_LABEL           = Scale
+
+# Coordinate Tracker
+COORDINATETRACKERTITLE          = Coordinate Tracker
\ No newline at end of file


Property changes on: trunk/widgets/CoordinateTracker
___________________________________________________________________
Added: bugtraq:number
   + true

Added: trunk/widgets/CoordinateTracker/CoordinateTracker.css
===================================================================
--- trunk/widgets/CoordinateTracker/CoordinateTracker.css	                        (rev 0)
+++ trunk/widgets/CoordinateTracker/CoordinateTracker.css	2013-06-05 13:09:09 UTC (rev 2732)
@@ -0,0 +1,11 @@
+body { font-family: Arial, Helvetica, sans-serif; }
+ul { list-style-type: none; }
+.epsgcode { 
+    font-size: 0.8em;
+    margin-top: 5px;
+    margin-left: -10px;
+}
+.coords { 
+    font-size: 0.7em;
+    margin-top: 2px; 
+}
\ No newline at end of file

Added: trunk/widgets/CoordinateTracker/CoordinateTracker.php
===================================================================
--- trunk/widgets/CoordinateTracker/CoordinateTracker.php	                        (rev 0)
+++ trunk/widgets/CoordinateTracker/CoordinateTracker.php	2013-06-05 13:09:09 UTC (rev 2732)
@@ -0,0 +1,63 @@
+<?php
+    $fusionMGpath = '../../layers/MapGuide/php/';
+    include $fusionMGpath . 'Common.php';
+    if (InitializationErrorOccurred())
+    {
+        DisplayInitializationErrorHTML();
+        exit;
+    }
+    SetLocalizedFilesPath(GetLocalizationPath());
+    if (isset($_REQUEST['locale'])) {
+        $locale = $_REQUEST['locale'];
+    } else {
+        $locale = GetDefaultLocale();
+    }
+    
+    $title = GetLocalizedString("COORDINATETRACKERTITLE", $locale);
+?>
+<html>
+    <head>
+        <title><?= $title ?></title>
+        <link rel="stylesheet" href="CoordinateTracker.css" />
+        <script type="text/javascript">
+        
+            var bReady = false;
+            var oWidget = null;
+            
+            function setWidget(widget) {
+                oWidget = widget;
+                var listEl = document.getElementById("ProjectionsList");
+                for (var code in oWidget.projections) {
+                    var el = document.createElement("li");
+                    var nameEl = document.createElement("strong");
+                    nameEl.setAttribute("class", "epsgcode");
+                    nameEl.innerHTML = code;
+                    var valueEl = document.createElement("div");
+                    valueEl.setAttribute("id", oWidget.getDomId(code));
+                    valueEl.setAttribute("class", "coords");
+                    el.appendChild(nameEl);
+                    el.appendChild(valueEl);
+                    listEl.appendChild(el);
+                }
+                oWidget.startListening();
+            }
+            
+            function loadMe() {
+                bReady = true;
+            }
+            
+            function unloadMe() {
+                if (oWidget)
+                    oWidget.deactivate();
+            }
+        
+        </script>
+    </head>
+    <body onload="loadMe()" onunload="unloadMe()">
+        <h3><?= $title ?></h3>
+        <hr/>
+        <ul id="ProjectionsList">
+        
+        </ul>
+    </body>
+</html>
\ No newline at end of file

Added: trunk/widgets/CoordinateTracker.js
===================================================================
--- trunk/widgets/CoordinateTracker.js	                        (rev 0)
+++ trunk/widgets/CoordinateTracker.js	2013-06-05 13:09:09 UTC (rev 2732)
@@ -0,0 +1,134 @@
+/*********************************************************************
+ * Class: Fusion.Widget.CoordinateTracker
+ *
+ * The CoordinateTracker widget allows the user to view mouse coordinates
+ * in various projections. The projections must be in EPSG format
+ *
+ * Inherits from:
+ *  - <Fusion.Widget>
+ ***********************************************************************/
+ 
+Fusion.Widget.CoordinateTracker = OpenLayers.Class(Fusion.Widget, {
+    isExclusive: false,
+    uiClass: Jx.Button,
+    
+    template: "x: {x}<br/> y: {y}",
+    taskPane: null,
+    olMapProj: null,
+    projections: {},
+    sWinFeatures: "menubar=no,location=no,resizable=no,status=no,width=250,height=300",
+
+    initializeWidget: function(widgetTag) {
+        var json = widgetTag.extension;
+        /*
+        <Projection>EPSG:4326</Projection>
+        <Projection>EPSG:900913</Projection>
+        */
+        if (json.Projection) {
+            for (var i = 0; i < json.Projection.length; i++) {
+                var code = json.Projection[i];
+                this.projections[code] = new OpenLayers.Projection(code);
+            }
+        }
+        
+        this.sTarget = json.Target ? json.Target[0] : "";
+        if (this.sTarget)
+            this.taskPane = new Fusion.Widget.CoordinateTracker.DefaultTaskPane(this);
+    },
+    getDomId: function(epsgCode) {
+        return epsgCode.replace(":", "_");
+    },
+    activate: function() {
+        if (this.taskPane) {
+            this.taskPane.loadDisplayPanel();
+        }
+    },
+    deactivate: function() {
+        this.stopListening();
+    },
+    startListening: function() {
+        this.olMapProj = this.getMap().oMapOL.getProjectionObject();
+        this.getMap().oMapOL.events.register("mousemove", this.taskPane, this.taskPane.updateCoordinates);
+        //console.log("start listening");
+    },
+    stopListening: function() {
+        if (this.olMapProj) {
+            this.olMapProj = null;
+            this.getMap().oMapOL.events.unregister("mousemove", this.taskPane, this.taskPane.updateCoordinates);
+            //console.log("stop listening");
+        }
+    }
+});
+
+Fusion.Widget.CoordinateTracker.DefaultTaskPane = OpenLayers.Class({
+    widget: null,
+    taskPaneWin: null,
+    panelUrl: "widgets/CoordinateTracker/CoordinateTracker.php",
+    map: null,
+    
+    initialize: function(widget) {
+        this.widget = widget;
+        this.map = this.widget.getMap().oMapOL;
+    },
+    
+    loadDisplayPanel: function() {
+        var url = Fusion.getFusionURL() + this.panelUrl;
+        var params = [];
+        params.push("LOCALE=" + Fusion.locale);
+        
+        if (url.indexOf("?") < 0) {
+            url += "?";
+        } else if (url.slice(-1) != "&") {
+            url += "&";
+        }
+        url += params.join("&");
+        var taskPaneTarget = Fusion.getWidgetById(this.widget.sTarget);
+        var outputWin = window;
+        if (taskPaneTarget) {
+            taskPaneTarget.setContent(url);
+            outputWin = taskPaneTarget.iframe.contentWindow;
+        } else {
+            outputWin = window.open(url, this.widget.sTarget, this.widget.sWinFeatures);
+        }
+        
+        this.taskPaneWin = outputWin;
+        var initFunction = OpenLayers.Function.bind(this.initPanel, this);
+        setTimeout(initFunction, 300);
+    },
+    
+    updateCoordinates: function(evt) {
+        lonLat = this.map.getLonLatFromPixel(evt.xy);
+        if (!lonLat)
+            return;
+        if (!this.widget.olMapProj)
+            return;
+        
+        for (var code in this.widget.projections) {
+            var txLonLat = lonLat.clone();
+            txLonLat.transform(this.widget.olMapProj, 
+                               this.widget.projections[code]); 
+            
+            var el = this.taskPaneWin.document.getElementById(this.widget.getDomId(code));
+            if (el) {
+                var template = this.widget.template.replace("{x}", txLonLat.lon)
+                                                   .replace("{y}", txLonLat.lat);
+                el.innerHTML = template;
+            }
+        }
+    },
+    
+    initPanel: function() {
+        var bReady = false;
+        try {
+            bReady = this.taskPaneWin.bReady;
+        } catch (e) {
+            if (!bReady) {
+                var initFunction = OpenLayers.Function.bind(this.initPanel, this);
+                setTimeout(initFunction, 300);
+                return;
+            }
+        }
+        
+        this.taskPaneWin.setWidget(this.widget);
+    }
+});

Added: trunk/widgets/widgetinfo/coordinatetracker.xml
===================================================================
--- trunk/widgets/widgetinfo/coordinatetracker.xml	                        (rev 0)
+++ trunk/widgets/widgetinfo/coordinatetracker.xml	2013-06-05 13:09:09 UTC (rev 2732)
@@ -0,0 +1,29 @@
+<WidgetInfo>
+  <Type>CoordinateTracker</Type>
+  <LocalizedType>CoordinateTracker</LocalizedType>
+  <Description>This widget displays mouse coordinates in various projections</Description>
+  <Location></Location>
+  <Label>Coordinate Tracker</Label>
+  <Tooltip>Click to view mouse coordinates in various projections</Tooltip>
+  <StatusText></StatusText>
+  <ImageUrl>images/icons.png</ImageUrl>
+  <ImageClass>coordinate-tracker</ImageClass>
+  <StandardUi>true</StandardUi>
+  <ContainableBy>Any</ContainableBy>
+  <Parameter>
+    <Name>Target</Name>
+    <Description>The frame, window, or TaskPane in which to display any UI for the widget. If empty, a new window is used</Description>
+    <Type>target</Type>
+    <Label>Target</Label>
+    <DefaultValue>TaskPane</DefaultValue>
+    <IsMandatory>true</IsMandatory>
+  </Parameter>
+  <Parameter>
+    <Name>Projection</Name>
+    <Description>Indicates a list of projections (as EPSG codes) to display coordinates in</Description>
+    <Type>xml</Type>
+    <Label>Projection</Label>
+    <DefaultValue></DefaultValue>
+    <IsMandatory>true</IsMandatory>
+  </Parameter>
+</WidgetInfo>



More information about the fusion-commits mailing list