wukong sun, What is the geo object? If it is a MapPoint than it's extent is null.
QiTian,I think your question is to ask how to create a default extent of the map. Usually, the mouseclick event not control the extent of the map. Like you said, the map extent is usually set with a static value by using Xmin, Ymin, Xmax, Ymax.I suggest you to read this link might helpful to you to understand the extent in Flex API:https://developers.arcgis.com/en/flex/guide/using-extent.htmlAlso, this link provide you the com.esri.ags property, it includes how to use extent syntax https://developers.arcgis.com/en/flex/api-reference/com/esri/ags/Map.html#extentHope this can help you.
var extent:Extent = geometry.extent; // returns null for MapPoint or Multipoint's with only one point if (extent) { map.zoomTo(geometry); } else { var mapPoint:MapPoint; if (geometry is MapPoint) { mapPoint = geometry as MapPoint; } else if (geometry is Multipoint) { var multipoint:Multipoint = geometry as Multipoint; if (multipoint.points && multipoint.points.length > 0) { mapPoint = multipoint.points[0]; } } if (mapPoint) { // make sure the infoWindow always points to the current (selected) feature map.infoWindow.show(mapPoint); // Zoom to 1/16th the size of the current extent. // This is the same as calling map.zoomIn() four times. map.zoom(1 / 16, mapPoint); if (!map.extent.contains(mapPoint)) { map.centerAt(mapPoint); } } }
Wukong Sun, Here is how you handle it (taken your esri code in popuprendereskin): var extent:Extent = geometry.extent; // returns null for MapPoint or Multipoint's with only one point if (extent) { map.zoomTo(geometry); } else { var mapPoint:MapPoint; if (geometry is MapPoint) { mapPoint = geometry as MapPoint; } else if (geometry is Multipoint) { var multipoint:Multipoint = geometry as Multipoint; if (multipoint.points && multipoint.points.length > 0) { mapPoint = multipoint.points[0]; } } if (mapPoint) { // make sure the infoWindow always points to the current (selected) feature map.infoWindow.show(mapPoint); // Zoom to 1/16th the size of the current extent. // This is the same as calling map.zoomIn() four times. map.zoom(1 / 16, mapPoint); if (!map.extent.contains(mapPoint)) { map.centerAt(mapPoint); } } }
map.extent = map.initialExtent; var resultlist:Array=new Array(); for each(var griphic:Graphic in featureSet.features) { var geo:Geometry= griphic.geometry; var pnt :MapPoint = geo as MapPoint ; map.centerAt(pnt); map.extent = map.extent.expand(0.2); break; }
map.scale = 2400;
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.