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);
}
}
}
Robert, thank you so much for your answer. I have test it in my project,and it worked at the beginnig.After I zoom in to the fisrt mappoint I go on want to zoom in to another mappoint,and then the problem appeared.The map extent continue to zoom in till to the limit. Now,what I want is that the map extent zoom in to the same scale at everytime I query a mappoint. This is my solution:
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;
}
This code control the map extent base on the initialExtent. So when the initialExtent change , we have to change the "expand()" . I'm looking for a better solution. Your great answer would be appreciated.Thanks again.