使用该函数的时候会出现第一次能正确定位,而第二次定位不正确的情况,解决办法是每次在调用该函数之前都调用一下map.reset()函数。
另外,不同的图层类型要使用不同的定位方式。以下是示例代码:
map.reset();

if (fLayer.getFeatureClass().equalsIgnoreCase("point"))
{
SimpleMarkerSymbol simpleMarker = new SimpleMarkerSymbol();
simpleMarker.setMarkerType(SimpleMarkerSymbol.STAR);
simpleMarker.setColor("255,0,0");
simpleMarker.setWidth(20);
map.displayFeatures(fLayer, expression, true, simpleMarker);


} else if (fLayer.getFeatureClass().equalsIgnoreCase("line"))
{
SimpleLineSymbol symbol = new SimpleLineSymbol();
symbol.setColor("255,0,0");
symbol.setTransparency(0.5);
symbol.setWidth(9);

map.displayFeatures(fLayer, expression, true, symbol);

} else
{
SimplePolygonSymbol symbol = new SimplePolygonSymbol();
symbol.setFillColor("255,0,0");
symbol.setTransparency(0.5);
symbol.setFillType(SimplePolygonSymbol.VERTICAL);
map.displayFeatures(fLayer, expression, true, symbol);
}
map.refresh();