Thanks Robert. Is that all I would need to make it work in 3.6?
Derek,
Here is the updated ConstrainedMap.as
package com.esri.viewer { import com.esri.ags.Map; import com.esri.ags.esri_internal; import com.esri.ags.events.ExtentEvent; import com.esri.ags.events.MapEvent; import com.esri.ags.geometry.Extent; import com.esri.ags.utils.ProjUtils; import flash.system.Capabilities; use namespace esri_internal; public class ConstrainedMap extends Map { private var m_cExtent:Extent = new Extent(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY); private var m_initialScale:Number = Number.POSITIVE_INFINITY; private var m_initialExtent:Extent = new Extent( Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY); private var lastDy:Number = 0; public function set constrainedExtent(value:Extent):void { m_cExtent = value; } public function get constrainedExtent():Extent { return m_cExtent; } public function ConstrainedMap() { this.openHandCursorVisible = true; this.extent = m_cExtent.esri_internal::duplicate(); this.addEventListener(MapEvent.LOAD, loadHandler ); } override public function set extent(value:Extent):void { const newScale:Number = ProjUtils.convertExtentToScale(value, width, Capabilities.screenDPI); // trace( newScale.toFixed(0), m_initialScale.toFixed(0)); // Make sure we do not go over the initial extent. if( newScale > m_initialScale ) { super.extent = m_initialExtent.esri_internal::duplicate();; } else { super.extent = value; } } private function loadHandler(event:MapEvent):void { this.removeEventListener(MapEvent.LOAD, loadHandler); // Note the low priority listener. this.addEventListener(ExtentEvent.EXTENT_CHANGE, extentChangeHandlerOnce, false, -99); this.addEventListener(ExtentEvent.EXTENT_CHANGE, extentChangeHandler); } /** * Handler used _once_ to get the initial map scale and extent. */ private function extentChangeHandlerOnce(event:ExtentEvent):void { this.removeEventListener(ExtentEvent.EXTENT_CHANGE, extentChangeHandlerOnce); m_initialScale = ProjUtils.convertExtentToScale(m_cExtent, width, Capabilities.screenDPI); m_initialExtent = m_cExtent; } private function extentChangeHandler(event:ExtentEvent):void { if(extent.contains(m_initialExtent)) { return; } var dx:Number, dy:Number; if(m_initialExtent.xmax < extent.xmax) { dx = extent.xmax - m_initialExtent.xmax; } else if(m_initialExtent.xmin > extent.xmin) { dx = extent.xmin - m_initialExtent.xmin; } else { dx = 0.0; } if(m_initialExtent.ymax < extent.ymax) { dy = extent.ymax - m_initialExtent.ymax; } else if(m_initialExtent.ymin > extent.ymin) { dy = extent.ymin - m_initialExtent.ymin; } else { dy = 0; } //trace( dx.toFixed(0), dy.toFixed(0)); if(dx.toFixed(0) !== "0." || dy.toFixed(0) !== "0.") { // Make sure the extent is set on the next display cycle. callLater(callLaterHandler, [dx,dy]); } } private function callLaterHandler(dx:Number, dy:Number):void { if(Math.abs(dy).toFixed(0) == Math.abs(lastDy).toFixed(0)){ //trace("exiting extent change"); return; } extent = new Extent(extent.xmin - dx, extent.ymin - dy, extent.xmax - dx, extent.ymax - dy); lastDy = dy; } } }
This has code to avoid the earthquake effect.
Has anyone compiled this successfully for 3.6?
Paul, As I explained to some one else a minute ago there is no compiling of just a certain portion of the Viewer. You make the changes in the source code and then compile the whole Flex Viewer project each time.
Hi,Is there a quick way to restrict the Max & Min bounding coordinates for a map application?I have a very localized Flex Viewer application and I don't want end users zooming out or away from the project area. Ideally if they try to pan past a certain bounding coordinate range then they will not be allowed to do so.Thanks all,Brendan
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.