<?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" creationComplete="application1_creationCompleteHandler(event)"> <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; import com.esri.ags.Graphic; import com.esri.ags.SpatialReference; import mx.events.FlexEvent; // 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 + ")"; } protected function application1_creationCompleteHandler(event:FlexEvent):void { // this.startExtent = new Extent(-82.92, 33.68, -71.67, 40.93,new SpatialReference()); // this.mapWMS.map.initialExtent = this.startExtent; // this.mapWMS.map.zoomToInitialExtent(); var graphic1:Graphic = new Graphic(); var sr1:SpatialReference = new SpatialReference(4326); var mappoint1:MapPoint = new MapPoint(55.773261,37.545827,sr1); graphic1.geometry = mappoint1; myGraphicsLayer.add(graphic1); } ]]> </fx:Script> <fx:Declarations> <esri:SimpleMarkerSymbol id="defaultSymbol" alpha="0.5" color="0x0000FF" size="13" style="circle"> <esri:SimpleLineSymbol/> </esri:SimpleMarkerSymbol> </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()"> <esri:extent> <esri:Extent xmin="3035000" ymin="4305000" xmax="3475000" ymax="10125000"> <esri:SpatialReference wkid="102100"/> <!-- same as tiled map service below --> </esri:Extent> </esri:extent> <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/> <esri:GraphicsLayer id="myGraphicsLayer" symbol="{defaultSymbol}"/> </esri:Map> </s:Application>
Solved! Go to Solution.
protected function application1_creationCompleteHandler(event:FlexEvent):void { // this.startExtent = new Extent(-82.92, 33.68, -71.67, 40.93,new SpatialReference()); // this.mapWMS.map.initialExtent = this.startExtent; // this.mapWMS.map.zoomToInitialExtent(); var graphic1:Graphic = new Graphic(); var sr1:SpatialReference = new SpatialReference(3857); var mappoint1:MapPoint = new MapPoint(55.773261,37.545827,sr1); var mappoint2:Geometry = WebMercatorUtil.geographicToWebMercator(mappoint1); graphic1.geometry = mappoint2; myGraphicsLayer.add(graphic1); } protected function application1_creationCompleteHandler(event:FlexEvent):void { // this.startExtent = new Extent(-82.92, 33.68, -71.67, 40.93,new SpatialReference()); // this.mapWMS.map.initialExtent = this.startExtent; // this.mapWMS.map.zoomToInitialExtent(); var graphic1:Graphic = new Graphic(); var sr1:SpatialReference = new SpatialReference(3857); var mappoint1:MapPoint = new MapPoint(55.773261,37.545827,sr1); var mappoint2:Geometry = WebMercatorUtil.geographicToWebMercator(mappoint1); graphic1.geometry = mappoint2; myGraphicsLayer.add(graphic1); } You're adding the map point in a geographic projection to a Web Mercator projection. You need to project its geometry to add it to the correct place
And is this location for Moscow? If so, your lat/long is switched.