|
POST
|
I've run some tests using a slight modification of the Map Extent and Mouse Coordinates sample, using different browser sizes with either the dynamic or tiled version of the same service. The reports the X and Y min/max as well as the scale of the map. I changed the size and shape of the window for each test. You can run the same code, changing the dimensions of the browser for each one. For each dynamic version, either the X Min/Max or the Y Min/Max are exactly what is used in the Extent tag. You'd have to get the browser proportions exactly right to get both X and Y extents to match up. For the tiled versions, notice that while the X and Y extents are not what you put in, the scale of each window is what the scale is shown for the tile LODs (see the map service page for them).
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:esri="http://www.esri.com/2008/ags"
pageTitle="Map Extent and Mouse Coordinates">
<!--
The current extent of the map is available directly through myMap.extent.
Similarly, the current scale is myMap.scale.
Other properties easily accessible is myMap.
To get the current coordinates of the mouse cursor, you can add an event listener for "MOUSE_MOVE"
on the map. In the listener you can access the current stage location using stageX and stageY.
Then use the toMapFromStage method to easily get those stage coordinates into map coordinates.
-->
<fx:Script>
<![CDATA[
import com.esri.ags.events.ExtentEvent;
import com.esri.ags.geometry.Extent;
import com.esri.ags.geometry.MapPoint;
import com.esri.ags.utils.WebMercatorUtil;
// when mouse (cursor) is on the map ...
private function loadHandler():void
{
myMap.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
}
// ... show coordinates of current (mouse) location
private function mouseMoveHandler(event:MouseEvent):void
{
const mapPoint:MapPoint = myMap.toMapFromStage(event.stageX, event.stageY);
const latlong:MapPoint = WebMercatorUtil.webMercatorToGeographic(mapPoint) as MapPoint;
mousecoords.text =
"x,y is " + mapPoint.x.toFixed(0) + "," + mapPoint.y.toFixed(0)
+ " and Lat/Long is: " + latlong.y.toFixed(6)
+ " / " + latlong.x.toFixed(6);
}
// convert current projected extent to geographic and show as such
protected function showExtentInGeographic(extent:Extent):String
{
const geoExtent:Extent = WebMercatorUtil.webMercatorToGeographic(myMap.extent) as Extent;
// return geoExtent.toString() + ".." ;
return " " + geoExtent.xmin.toFixed(6)
+ ", " + geoExtent.ymin.toFixed(6)
+ ", " + geoExtent.xmax.toFixed(6)
+ ", " + geoExtent.ymax.toFixed(6)
+ " (wkid: " + geoExtent.spatialReference.wkid + ")";
}
]]>
</fx:Script>
<fx:Declarations>
<esri:Extent id="initialExtent" xmin="-13001000" ymin="3292000" xmax="-8812000" ymax="6154000">
<esri:SpatialReference wkid="102100"/>
</esri:Extent>
</fx:Declarations>
<s:layout>
<s:VerticalLayout paddingTop="6"/>
</s:layout>
<s:HGroup>
<s:Label fontWeight="bold" text="Current map extent:"/>
<s:RichEditableText editable="false" text='xmin="{myMap.extent.xmin.toFixed(0)}" ymin="{myMap.extent.ymin.toFixed(0)}" xmax="{myMap.extent.xmax.toFixed(0)}" ymax="{myMap.extent.ymax.toFixed(0)}" (wkid="{myMap.spatialReference.wkid}")'/>
</s:HGroup>
<s:HGroup>
<s:Label fontWeight="bold" text="Current map extent (in geographic):"/>
<s:RichEditableText editable="false" text="{showExtentInGeographic(myMap.extent)}"/>
</s:HGroup>
<s:HGroup>
<s:Label fontWeight="bold" text="Current Mouse Coordinates:"/>
<s:RichEditableText id="mousecoords"
editable="false"
text="Move the mouse over the map to see its current coordinates..."/>
</s:HGroup>
<s:HGroup>
<s:Label fontWeight="bold" text="Current map scale is"/>
<s:RichEditableText editable="false" text="1:{myMap.scale.toFixed(0)} (level {myMap.level})"/>
</s:HGroup>
<esri:Map id="myMap" load="loadHandler()" extent="{initialExtent}">
<!-- <esri:extent>
<esri:Extent xmin="3035000" ymin="4305000" xmax="3475000" ymax="10125000">
<esri:SpatialReference wkid="102100"/>
</esri:Extent>
</esri:extent>-->
<!-- <esri:ArcGISDynamicMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
--> <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
</esri:Map>
</s:Application>
... View more
04-12-2011
11:13 AM
|
0
|
0
|
1731
|
|
POST
|
Think of it this way. Say you've set the extent so the X difference is 100,000 units. You've set the size of your map to be 1 unit wide, which makes the scale of your displayed map 1:100,000. If the tiled layer is set up with the Web mercator standard levels of detail at 1:144,447.638572 and 1:72,223.819286, the extent of the map will have to change to fit one of those scale. When you're using tiled layers, you cannot set arbitary scales, but have to use the pre-determined scales. If you're using only dynamic layers, you can set any scale you'd like.
... View more
04-07-2011
09:31 AM
|
0
|
0
|
1731
|
|
POST
|
The ArcGIS Viewer for Flex forum has been set up for your FlexViewer questions.
... View more
04-07-2011
07:02 AM
|
0
|
0
|
568
|
|
POST
|
Hi Daniel, I guess I'm not understanding your issue. If I just open the form using MyForm.Show(), then it appears in front of the ArcMap window. If I click on ArcMap, then the ArcMap window will move in front of the form. I can click on the form in the Taskbar to bring it back in front of ArcMap. I work in NOS in the Biogeography Branch. I think we might have crossed paths in working with data in the Gulf of Maine.
... View more
04-06-2011
11:37 AM
|
0
|
0
|
206
|
|
POST
|
Here's an example. First is the Window Wrapper class
Public Class Win32HWNDWrapper
Implements System.Windows.Forms.IWin32Window
Private _hwnd As System.IntPtr
Public ReadOnly Property Handle As System.IntPtr Implements System.Windows.Forms.IWin32Window.Handle
Get
Return _hwnd
End Get
End Property
Public Sub New(ByVal Handle As System.IntPtr)
_hwnd = Handle
End Sub
End Class
and the code to open a form
MyForm.Show(New Win32HWNDWrapper(m_application.hWnd))
... View more
04-06-2011
10:10 AM
|
0
|
0
|
1470
|
|
POST
|
The TimeSliderSkin (along with many other skins) are distributed with the version 2.x of the API. The skin is located in ArcGIS_Flex\skins\src\com\esri\ags\skins
... View more
04-06-2011
06:07 AM
|
0
|
0
|
568
|
|
POST
|
This is more of an issue with resolution of the basemaps you're using and the size of their tiles. Tiled map services will show the data at a specific scale, which is dependent on the size of your map. If the extent you've designated doesn't match the tiled service's scale, I believe it zooms in to a smaller extent. You'll be able to have the precise extent when using a dynamic service, but tiles services are a bit more finicky.
... View more
04-04-2011
08:04 AM
|
0
|
0
|
1731
|
|
POST
|
This makes me wonder if the menu's OnDemand also needs to be set.
... View more
03-31-2011
09:26 AM
|
0
|
0
|
796
|
|
POST
|
Have you added the OnDemand attribute to the button in the Config.esriaddinx file? See the help for more information about Delay loading
... View more
03-31-2011
07:27 AM
|
0
|
0
|
796
|
|
POST
|
This is the code that disables a command button if ArcMap is in Layout mode. Don't forget to also make the changes to the Config.esriaddinx file discussed here to make the button enabled or disabled on startup.
Protected Overrides Sub OnUpdate()
'Enabled = My.ArcMap.Application IsNot Nothing
If TypeOf pMxDoc.ActiveView Is ESRI.ArcGIS.Carto.IPageLayout Then
Enabled = False
ElseIf TypeOf pMxDoc.ActiveView Is ESRI.ArcGIS.Carto.IMap Then
Enabled = True
End If
End Sub
... View more
03-31-2011
05:33 AM
|
0
|
0
|
950
|
|
POST
|
You can find the older versions of the Flash Debug player here
... View more
03-28-2011
09:53 AM
|
0
|
0
|
435
|
|
POST
|
Take a look at Mansour Raad's blog on constraining the extent
... View more
03-23-2011
09:23 AM
|
0
|
0
|
328
|
|
POST
|
This is one of the tools that are only available with an ArcEditor or ArcInfo License. The help topics on the tools shows what license level are required to run them.
... View more
03-23-2011
09:17 AM
|
0
|
0
|
762
|
|
POST
|
This would be more useful in the ArcGIS Viewer for Flex forum
... View more
03-23-2011
05:28 AM
|
0
|
0
|
1601
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | a month ago | |
| 2 | a month ago | |
| 1 | 11-18-2025 12:30 PM | |
| 2 | 11-18-2025 06:53 AM | |
| 1 | 11-17-2025 06:38 AM |
| Online Status |
Offline
|
| Date Last Visited |
14 hours ago
|