Просмотр исходного кода

TableAjaxMap: zoom, some test buttons

Piotr Labudda 11 лет назад
Родитель
Сommit
ade02525ed

+ 35 - 29
SE/se-lib/TableAjax.php

@@ -887,7 +887,8 @@ class TableAjax extends ViewAjax {
 								case "geom":
 									cellCnt.html('<i class="cell-mapfld icon-map-marker"></i>');
 									cellCnt.on('click', {recordID: cellID, fieldValue: val}, function(e) {
-										console.log('clicked:', e.data.recordID, 'val:', e.data.fieldValue);
+										priv.mapEditorShow();
+										_mapEditor.TableAjaxMapZoomToExtent(e.data.fieldValue);
 									});
 									break;
 							}
@@ -1525,38 +1526,43 @@ class TableAjax extends ViewAjax {
 			_mapEditorDialog.dialog("destroy");
 		}
 
+		priv.mapEditorShow = function() {
+			priv.options.mapEditor = true;
+			_mapEditorWrap.show();
+			_mapEditor.TableAjaxMap({
+				wpsUrl: 'http://biuro.biall-net.pl/wps',
+				wfsUrl: 'http://biuro.biall-net.pl/wps',
+				layerName: '<?php echo $this->getLabelHtml(); ?>',
+				onfeatureselect: function() {
+					// this.selectedFeatures
+					console.log('onfeatureselect (',this.selectedFeatures.length,'): ', this);
+				},
+				onfeatureselect: function() {
+					console.log('onfeatureselect (',this.selectedFeatures.length,'): ', this);
+				}
+			});
+
+			_mapEditorDialog = _mapEditorWrap.dialog({
+				width: 540,
+				minWidth: 400,
+				minHeight: 300,
+				resizeStop: function(){
+					_mapEditor.TableAjaxMapUpdateSize(); //to prevent drag-zoom error
+				},
+				dragStop: function(){
+					_mapEditor.TableAjaxMapUpdateSize(); //to prevent drag-zoom error
+				}
+			});
+			_mapEditorWrap.bind('dialogclose', function(e) {
+				priv.options.mapEditor = false;
+			});
+		}
+
 		priv.mapEditorChanged = function(e) {
 			console.log('mapEditorChanged option(',priv.options.mapEditor,') e:', e);
 			priv.options.mapEditor = !priv.options.mapEditor;
 			if (priv.options.mapEditor) {
-				_mapEditorWrap.show();
-				_mapEditor.TableAjaxMap({
-					wpsUrl: 'http://biuro.biall-net.pl/wps',
-					wfsUrl: 'http://biuro.biall-net.pl/wps',
-					layerName: '<?php echo $this->getLabelHtml(); ?>',
-					onfeatureselect: function() {
-						// this.selectedFeatures
-						console.log('onfeatureselect (',this.selectedFeatures.length,'): ', this);
-					},
-					onfeatureselect: function() {
-						console.log('onfeatureselect (',this.selectedFeatures.length,'): ', this);
-					}
-				});
-
-				_mapEditorDialog = _mapEditorWrap.dialog({
-					width: 540,
-					minWidth: 400,
-					minHeight: 300,
-					resizeStop: function(){
-						_mapEditor.TableAjaxMapUpdateSize(); //to prevent drag-zoom error
-					},
-					dragStop: function(){
-						_mapEditor.TableAjaxMapUpdateSize(); //to prevent drag-zoom error
-					}
-				});
-				_mapEditorWrap.bind('dialogclose', function(e) {
-					priv.options.mapEditor = false;
-				});
+				priv.mapEditorShow();
 			}
 			else {
 				priv.mapEditorHide();

+ 63 - 9
SE/se-lib/TableAjaxMap.php

@@ -33,6 +33,8 @@ class TableAjaxMap {
 .TableAjaxMap { width:100%; height:<?php echo $this->_height; ?>px; }
 .olControlEditingToolbar .olControlModifyFeatureItemInactive { background-image:url(stuff/open-layers/theme/default/img/draw_point_off.png); }
 .olControlEditingToolbar .olControlModifyFeatureItemActive   { background-image:url(stuff/open-layers/theme/default/img/draw_point_on.png); }
+.olControlEditingToolbar .olControlRefreshItemInactive { background-image: url(stuff/open-layers/theme/default/img/refresh_feature_off.png); }
+.olControlEditingToolbar .olControlRefreshItemActive { background-image: url(stuff/open-layers/theme/default/img/refresh_feature_on.png); }
 .olControlLayerSwitcher .layersDiv { border-radius:10px 0 0 10px; opacity:0.75; filter:alpha(opacity=75); }
 .notsupported { color:red; }
 .TableAjaxMap .layersDiv input { margin:0; }
@@ -163,22 +165,59 @@ OpenLayers.ProxyHost = "index-ajax.php?_zasobID=<?php echo $this->_zasobID; ?>&_
 				title: "Select feature"
 			})]);
 			toolbar.addControls([
-				new OpenLayers.Control.SelectFeature(
-				_layer,
-				{
-					clickout: false, toggle: false,
-					multiple: false, hover: false,
+				new OpenLayers.Control.SelectFeature(_layer, {
+					title: "Select Test",
+					clickout: false,
+					toggle: false,
+					multiple: false,
+					hover: false,
 					toggleKey: "ctrlKey", // ctrl key removes from selection
 					multipleKey: "shiftKey", // shift key adds to selection
 					box: true
 				})
 			]);
+			toolbar.addControls([
+				new OpenLayers.Control.Button({
+					title: "Zoom Test",
+					displayClass: "olControlZoomToPoly",
+					trigger: function() {
+						var multiPolygon = OpenLayers.Geometry.fromWKT("MULTIPOLYGON(((2072016.74395199 7234076.79293037,2072016.74395199 7234115.01144451,2072131.3994944 7234115.01144451,2072131.3994944 7234076.79293037,2072016.74395199 7234076.79293037)))").getBounds();
+						_map.zoomToExtent(multiPolygon);
+					}
+				})
+			]);
+			var btnRefresh = new OpenLayers.Control.Button({
+				title: "Refresh",
+				displayClass: "olControlRefresh",
+				trigger: function() {
+					_layer.refresh({force: true});
+				}
+			});
+			toolbar.addControls([btnRefresh]);
 
 			var extent = new OpenLayers.Bounds(
 				2035059.4410645328, 7200979.560689885, 2113330.958028555, 7279251.0776539035
 			);
 
-			var gphy =  new OpenLayers.Layer.OSM("Mapa");
+			var gphy =  new OpenLayers.Layer.OSM("Mapa", null, {
+				resolutions: [156543.03390625, 78271.516953125, 39135.7584765625,
+					19567.87923828125, 9783.939619140625, 4891.9698095703125,
+					2445.9849047851562, 1222.9924523925781, 611.4962261962891,
+					305.74811309814453, 152.87405654907226, 76.43702827453613,
+					38.218514137268066, 19.109257068634033, 9.554628534317017,
+					4.777314267158508, 2.388657133579254, 1.194328566789627,
+					0.5971642833948135, 0.25, 0.1, 0.05],
+				serverResolutions: [156543.03390625, 78271.516953125, 39135.7584765625,
+					19567.87923828125, 9783.939619140625,
+					4891.9698095703125, 2445.9849047851562,
+					1222.9924523925781, 611.4962261962891,
+					305.74811309814453, 152.87405654907226,
+					76.43702827453613, 38.218514137268066,
+					19.109257068634033, 9.554628534317017,
+					4.777314267158508, 2.388657133579254,
+					1.194328566789627, 0.5971642833948135],
+				transitionEffect: 'resize'
+			});
 
 			_map = new OpenLayers.Map(_nodeMapId, {
 				projection: new OpenLayers.Projection("EPSG:900913"),
@@ -502,6 +541,11 @@ OpenLayers.ProxyHost = "index-ajax.php?_zasobID=<?php echo $this->_zasobID; ?>&_
 			_map.updateSize();
 		};
 
+		publ.zoomToExtent = function(extent) {
+			var extentBounds = OpenLayers.Geometry.fromWKT(extent).getBounds();
+			_map.zoomToExtent(extentBounds);
+		};
+
 		publ.init = function(options) {
 			if (priv.options.debug) console.log('TableAjaxMap initialization...', options);
 			//merge supplied options with defaults
@@ -515,15 +559,25 @@ OpenLayers.ProxyHost = "index-ajax.php?_zasobID=<?php echo $this->_zasobID; ?>&_
 	$.fn.TableAjaxMapUpdateSize = function(options) {
 		options = options || {};
 		return this.each(function() {
-			options.id = this;
-			if ($(this).data('TableAjaxMap')) {
-				var tblAjaxMap = $(this).data('TableAjaxMap');
+			var tblAjaxMap = $(this).data('TableAjaxMap');
+			if (tblAjaxMap) {
 				tblAjaxMap.updateSize();
 			}
 		});
 		return this;
 	};
 
+	$.fn.TableAjaxMapZoomToExtent = function(extent) {
+		if (!extent) return;
+		return this.each(function() {
+			var tblAjaxMap = $(this).data('TableAjaxMap');
+			if (tblAjaxMap) {
+				tblAjaxMap.zoomToExtent(extent);
+			}
+		});
+		return this;
+	};
+
 	$.fn.TableAjaxMap = function(options) {
 		options = options || {};
 		return this.each(function() {

BIN
SE/stuff/open-layers/theme/default/img/draw_point_off.png


BIN
SE/stuff/open-layers/theme/default/img/draw_point_on.png


BIN
SE/stuff/open-layers/theme/default/img/refresh_feature_off.png


BIN
SE/stuff/open-layers/theme/default/img/refresh_feature_on.png