[Commits] r1789 - in sandbox/cmoullet/ux: . ReverseGeocoder ReverseGeocoder/examples ReverseGeocoder/ux ReverseGeocoder/ux/control

commits at geoext.org commits at geoext.org
Wed Jan 20 20:33:51 CET 2010


Author: cmoullet
Date: 2010-01-20 20:33:51 +0100 (Wed, 20 Jan 2010)
New Revision: 1789

Added:
   sandbox/cmoullet/ux/ReverseGeocoder/
   sandbox/cmoullet/ux/ReverseGeocoder/examples/
   sandbox/cmoullet/ux/ReverseGeocoder/examples/ReverseGeocoderExample.html
   sandbox/cmoullet/ux/ReverseGeocoder/examples/ReverseGeocoderExample.js
   sandbox/cmoullet/ux/ReverseGeocoder/ux/
   sandbox/cmoullet/ux/ReverseGeocoder/ux/control/
   sandbox/cmoullet/ux/ReverseGeocoder/ux/control/ReverseGeocoderClick.js
Log:
ReverseGeocoder proto

Added: sandbox/cmoullet/ux/ReverseGeocoder/examples/ReverseGeocoderExample.html
===================================================================
--- sandbox/cmoullet/ux/ReverseGeocoder/examples/ReverseGeocoderExample.html	                        (rev 0)
+++ sandbox/cmoullet/ux/ReverseGeocoder/examples/ReverseGeocoderExample.html	2010-01-20 19:33:51 UTC (rev 1789)
@@ -0,0 +1,39 @@
+<html>
+<head>
+    <title>GeoExt Reverse Geocoder Example</title>
+    <script type="text/javascript" src="http://extjs.cachefly.net/builds/ext-cdn-771.js"></script>
+    <link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-2.2.1/resources/css/ext-all.css" />
+    <link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-2.2.1/examples/shared/examples.css" />
+    <!-- Google Maps API for "localhost" -->
+    <!--
+    <script src='http://maps.google.com/maps?file=api&amp;key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ'></script>
+    <script type="text/javascript" src="http://www.google.com/jsapi?key=ABQIAAAAY-I0w1WyNCVHbxpuwQWMpRTv_-xvSZ6KJmWSkQfCJoxbiB7tyBQ1ey_kgwA_p7sbTQSTOBeMyXtXkA"></script>
+    -->
+    <!-- 192.168.1.44 -->
+    <!--
+    <script src='http://maps.google.com/maps?file=api&amp;key=ABQIAAAAY-I0w1WyNCVHbxpuwQWMpRSIMweZSjbRtcUk2F5YNqLnri0MahTrQJRaRPWFP0OUB1b6unv37Jg7vQ'></script>
+    <script type="text/javascript" src="http://www.google.com/jsapi?key=ABQIAAAAY-I0w1WyNCVHbxpuwQWMpRSIMweZSjbRtcUk2F5YNqLnri0MahTrQJRaRPWFP0OUB1b6unv37Jg7vQ"></script>
+    -->
+    <!-- 10.27.10.44  -->
+    <!--
+    <script src='http://maps.google.com/maps?file=api&amp;key=ABQIAAAAY-I0w1WyNCVHbxpuwQWMpRQg15vMUgV9rqK5U3tGsPdx8x_OsBTeBHQ0wK75MLc8dB7yu0cRx36VJQ'></script>
+    <script type="text/javascript" src="http://www.google.com/jsapi?key=ABQIAAAAY-I0w1WyNCVHbxpuwQWMpRQg15vMUgV9rqK5U3tGsPdx8x_OsBTeBHQ0wK75MLc8dB7yu0cRx36VJQ"></script>
+    -->
+
+    <!-- Google Maps API for "dev.geoext.org" -->
+    <script type="text/javascript" src='http://maps.google.com/maps?file=api&amp;key=ABQIAAAAY-I0w1WyNCVHbxpuwQWMpRTv_-xvSZ6KJmWSkQfCJoxbiB7tyBQ1ey_kgwA_p7sbTQSTOBeMyXtXkA'></script>
+    <script type="text/javascript" src="http://www.google.com/jsapi?key=ABQIAAAAY-I0w1WyNCVHbxpuwQWMpRTv_-xvSZ6KJmWSkQfCJoxbiB7tyBQ1ey_kgwA_p7sbTQSTOBeMyXtXkA"></script>
+
+    <script type="text/javascript" src="http://openlayers.org/api/2.8/OpenLayers.js"></script>
+    <script type="text/javascript" src="../../../trunk/geoext/lib/GeoExt.js"></script>
+
+    <script type="text/javascript" src="http://dev.geoext.org/ux/GeoNamesSearchCombo/ux/widgets/form/GeoNamesSearchCombo.js"></script>
+    <script type="text/javascript" src="../ux/control/ReverseGeocoderClick.js"></script>
+
+
+    <script type="text/javascript" src="ReverseGeocoderExample.js"></script>
+
+</head>
+<body>
+</body>
+</html>
\ No newline at end of file

Added: sandbox/cmoullet/ux/ReverseGeocoder/examples/ReverseGeocoderExample.js
===================================================================
--- sandbox/cmoullet/ux/ReverseGeocoder/examples/ReverseGeocoderExample.js	                        (rev 0)
+++ sandbox/cmoullet/ux/ReverseGeocoder/examples/ReverseGeocoderExample.js	2010-01-20 19:33:51 UTC (rev 1789)
@@ -0,0 +1,94 @@
+var mapPanel;
+
+var treePanel;
+
+var viewport;
+
+var layer;
+
+Ext.onReady(function() {
+    Ext.BLANK_IMAGE_URL = '../../../trunk/ext/resources/images/default/s.gif';
+    OpenLayers.ImgPath = '../../../trunk/openlayers/img/';
+
+    var options = {
+        projection: "EPSG:900913",
+        units: "m",
+        maxResolution: 156543.0339,
+        numZoomLevels: 24,
+        maxExtent: new OpenLayers.Bounds(-20037508, -20037508,
+                20037508, 20037508.34)
+    };
+
+    var map = new OpenLayers.Map(options);
+
+    var googlem = new OpenLayers.Layer.Google("Google Streets", {'sphericalMercator': true},{isBaseLayer: true,buffer: 0});
+    var googles = new OpenLayers.Layer.Google("Google Satellite", { 'type': G_SATELLITE_MAP,'sphericalMercator': true},{isBaseLayer: true,buffer: 0});
+    var osm = new OpenLayers.Layer.OSM("OSM", {isBaseLayer: true,buffer: 0});
+
+    map.addLayers([googles, googlem, osm]);
+
+    map.googleKey = 'ABQIAAAAY-I0w1WyNCVHbxpuwQWMpRTv_-xvSZ6KJmWSkQfCJoxbiB7tyBQ1ey_kgwA_p7sbTQSTOBeMyXtXkA';
+
+    var mouse = new OpenLayers.Control.MousePosition();
+
+    map.addControl(mouse);
+    mouse.activate();
+
+    var clickControl = new GeoExt.ux.ReverseGeocoderClick({
+        handlerOptions: {
+            "single": true
+        },
+        map: map
+    });
+    map.addControl(clickControl);
+    clickControl.activate();
+
+    var treeItem = new Ext.tree.TreePanel({
+        border: false,
+        root: new GeoExt.tree.LayerContainer({
+            text: 'Map Layers',
+            leaf: false,
+            expanded: true
+        }),
+        enableDD: true
+    });
+
+    var geoNameSearchCombo = new GeoExt.ux.form.GeoNamesSearchCombo({
+        map: map,
+        zoom: 16
+    });
+
+    viewport = new Ext.Viewport({
+        layout: "border",
+        id: 'mainViewport',
+        items: [
+            {
+                region: "center",
+                id: "mappanel",
+                title: "2D Map",
+                xtype: "gx_mappanel",
+                map: map,
+                tbar: [geoNameSearchCombo]
+            },
+            {
+                region: "west",
+                id: "treepanel",
+                title: "Layer Tree",
+                width: 200
+            },
+            {
+                region: "south",
+                layout: 'fit',
+                id: "readme",
+                title: 'README',
+                margins: {left: 5,top: 5, bottom: 5, right: 5},
+                html: '<p style="font-size:12pt;color:#15428B;font-weight:bold;margin:5">Reverse Geocoder Example</p>'
+            }
+        ]
+    });
+
+    treePanel = Ext.getCmp("treepanel");
+    treePanel.add(treeItem);
+    treePanel.doLayout();
+    viewport.doLayout();
+});
\ No newline at end of file

Added: sandbox/cmoullet/ux/ReverseGeocoder/ux/control/ReverseGeocoderClick.js
===================================================================
--- sandbox/cmoullet/ux/ReverseGeocoder/ux/control/ReverseGeocoderClick.js	                        (rev 0)
+++ sandbox/cmoullet/ux/ReverseGeocoder/ux/control/ReverseGeocoderClick.js	2010-01-20 19:33:51 UTC (rev 1789)
@@ -0,0 +1,108 @@
+/**
+ * Copyright (c) 2008-2009 The Open Source Geospatial Foundation
+ *
+ * Published under the BSD license.
+ * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text
+ * of the license.
+ */
+
+/** api: (define)
+ *  module = GeoExt.ux
+ *  class = ReverseGeocoderClick
+ */
+
+Ext.namespace('GeoExt.ux');
+
+/** api: constructor
+ *  .. class:: ReverseGeocoderClick(options)
+ *
+ *      Create a click control
+ *      Extends ``OpenLayers.Control``
+ */
+GeoExt.ux.ReverseGeocoderClick = OpenLayers.Class(OpenLayers.Control, {
+
+    /** api: property[defaultHandlerOptions]
+     *  Default options.
+     */
+    defaultHandlerOptions: {
+        'single': true,
+        'double': false,
+        'pixelTolerance': 0,
+        'stopSingle': false,
+        'stopDouble': false
+    },
+
+    /** private: method[initialize]
+     *  Initializes the control
+     */
+    initialize: function(options) {
+        this.handlerOptions = OpenLayers.Util.extend({}, this.defaultHandlerOptions);
+        OpenLayers.Control.prototype.initialize.apply(this, arguments);
+        this.handler = new OpenLayers.Handler.Click(this, {
+            'click': this.onClick,
+            'dblclick': this.onDblclick},
+                this.handlerOptions
+                );
+    },
+
+    /** private: method[onClick]
+     */
+    onClick: function(evt) {
+        var lonlat = this.map.getLonLatFromViewPortPx(evt.xy);
+        lonlat.transform(this.map.getProjectionObject(), new OpenLayers.Projection("EPSG:4326"));
+
+        // Create empty proxy
+        this.proxy = new Ext.data.ScriptTagProxy({
+            url: 'to_be_replaced',
+            nocache: false
+        });
+
+        this.proxy.on(
+                'beforeload', function() {
+            this.proxy.url = "http://maps.google.com/maps/geo?q=" + lonlat.lat + "," + lonlat.lon + "&output=json&sensor=true&key=" + this.map.googleKey;
+        }, this);
+
+        this.geocoderStore = new Ext.data.Store({
+            proxy: this.proxy,
+            reader: new Ext.data.JsonReader({
+                root: 'Placemark',
+                fields: [
+                    {
+                        name: 'address'
+                    }
+                ]
+            })
+        });
+
+        this.geocoderStore.on(
+                'load', function(store) {
+
+            var placemark = store.reader.jsonData.Placemark[0];
+            if (this.map.mypopup) {
+                this.map.mypopup.destroy();
+            }
+            var position =  new OpenLayers.LonLat(placemark.Point.coordinates[0], placemark.Point.coordinates[1]);
+            position.transform(new OpenLayers.Projection("EPSG:4326"), this.map.getProjectionObject());
+            this.map.mypopup = new OpenLayers.Popup.FramedCloud(
+                    "Chicken",
+                    position,
+                    new OpenLayers.Size(100, 100),
+                    placemark.address,
+                    null,
+                    true,
+                    null);
+
+            this.map.addPopup(this.map.mypopup);
+        }, this);
+
+        this.geocoderStore.load();
+
+    },
+
+    /** private: method[onDblclick]
+     *  Not implemented
+     */
+    onDblclick: function(evt) {
+        alert('doubleClick');
+    }
+});



More information about the Commits mailing list