Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 是否从ItemizeOverlay中删除特定的地质点?_Android_Itemizedoverlay - Fatal编程技术网

Android 是否从ItemizeOverlay中删除特定的地质点?

Android 是否从ItemizeOverlay中删除特定的地质点?,android,itemizedoverlay,Android,Itemizedoverlay,我有一张地图,上面有很多点,添加到一个ItemizedOverlay中 OverlayItem overlayItem = new OverlayItem(theGeoPoint, title, description); itemizedOverlay.addOverlay(overlayItem); mapOverlays.add(itemizedOverlay); 有没有办法从itemizedOverlay中删除特定点 例如,假设我在不同的纬度/经度添加了很多点,我希望删除前面添加的纬度

我有一张地图,上面有很多点,添加到一个ItemizedOverlay中

OverlayItem overlayItem = new OverlayItem(theGeoPoint, title, description);
itemizedOverlay.addOverlay(overlayItem);
mapOverlays.add(itemizedOverlay);
有没有办法从itemizedOverlay中删除特定点

例如,假设我在不同的纬度/经度添加了很多点,我希望删除前面添加的纬度32.3121212和经度33.1230912处的点

我如何才能删除这一点

我真的需要这个,所以我希望有人能帮我

谢谢

完整故事场景(如果您对如何解决此问题有不同的想法):
将从数据库捕获的事件添加到映射。现在,当从数据库中删除事件时,我希望同步映射并仅删除已删除的事件。(请不要建议我重新下载除已删除点之外的所有点,尽管我已经想到了这一点,但这不是我要执行的操作的选项。:p)

使用地质点阵列创建地图覆盖并覆盖绘制功能:

public class MapOverlay extends Overlay 
{

    private ArrayList<GeoPoints>points;
    ...


    @Override
    public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) 
    {
            super.draw(canvas, mapView, shadow);      
            int len = points.size();  
            if(len > 0)
            {
                for(int i = 0; i < len; i++)
                {
                   // do with your points whatever you want
                   // you connect them, draw a bitmap over them  and etc.
                   // for example:
                   Bitmap bmp = BitmapFactory.decodeResource(res, R.drawable.pointer);
                   mapView.getProjection().toPixels(points.get(i), screenPts);
                   canvas.drawBitmap(bmp, screenPts.x-bmp.getWidth()/2, screenPts.y - bmp.getHeight()/2, null);  
                } 
            }
    }

    public void addPoint(GeoPoint p)
    {
       // add point to the display array
    }

    public void removePointByIndex(int i)
    {
       points.remove(i);
    }

    public void removePointByCordinate(Double lat, Double lng)
    {
        int index = -1;
        int len = points.size();  
        if(len > 0)
        {
                for(int i = 0; i < len; i++)
                {
                     if((int)(lat*1E6) == points.get(i).getLatitudeE6() && (int)(lng*1E6) == points.get(i).getLongitudeE6())
                     {
                          index = i;
                     }
                } 
            }

            if(index != -1)
            {
                points.remove(index);
            }
        }
    }

    public void removePoint(GeoPoint p)
    {
        int index = -1;
        int len = points.size();  
        if(len > 0)
        {
                for(int i = 0; i < len; i++)
                {
                     if(p == points.get(i))
                     {
                          index = i;
                     }
                } 
            }

            if(index != -1)
            {
                points.remove(index);
            }
        }
    }

}
公共类MapOverlay扩展了覆盖
{
私人阵列点;
...
@凌驾
公共布尔绘制(画布画布、地图视图、地图视图、布尔阴影、长时间)
{
super.draw(画布、地图视图、阴影);
int len=points.size();
如果(len>0)
{
对于(int i=0;i0)
{
对于(int i=0;i0)
{
对于(int i=0;i
(我没有在课堂上进行测试)

然后在MapActivity类中,您可以:

MapView mapView = (MapView) findViewById(R.id.mapview);
mapView.setClickable(true);
MapOverlay mapOverlay = new MapOverlay();                       
List<Overlay> listOfOverlays = mapView.getOverlays();
listOfOverlays.add(mapOverlay);
MapView MapView=(MapView)findViewById(R.id.MapView);
mapView.setClickable(真);
MapOverlay MapOverlay=新的MapOverlay();
List ListoForLays=mapView.getOverlays();
添加(映射覆盖);

尝试谷歌一些谷歌地图教程,也许你会找到更多的解决方案。

使用地理点阵列创建地图覆盖,并覆盖绘图功能:

public class MapOverlay extends Overlay 
{

    private ArrayList<GeoPoints>points;
    ...


    @Override
    public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) 
    {
            super.draw(canvas, mapView, shadow);      
            int len = points.size();  
            if(len > 0)
            {
                for(int i = 0; i < len; i++)
                {
                   // do with your points whatever you want
                   // you connect them, draw a bitmap over them  and etc.
                   // for example:
                   Bitmap bmp = BitmapFactory.decodeResource(res, R.drawable.pointer);
                   mapView.getProjection().toPixels(points.get(i), screenPts);
                   canvas.drawBitmap(bmp, screenPts.x-bmp.getWidth()/2, screenPts.y - bmp.getHeight()/2, null);  
                } 
            }
    }

    public void addPoint(GeoPoint p)
    {
       // add point to the display array
    }

    public void removePointByIndex(int i)
    {
       points.remove(i);
    }

    public void removePointByCordinate(Double lat, Double lng)
    {
        int index = -1;
        int len = points.size();  
        if(len > 0)
        {
                for(int i = 0; i < len; i++)
                {
                     if((int)(lat*1E6) == points.get(i).getLatitudeE6() && (int)(lng*1E6) == points.get(i).getLongitudeE6())
                     {
                          index = i;
                     }
                } 
            }

            if(index != -1)
            {
                points.remove(index);
            }
        }
    }

    public void removePoint(GeoPoint p)
    {
        int index = -1;
        int len = points.size();  
        if(len > 0)
        {
                for(int i = 0; i < len; i++)
                {
                     if(p == points.get(i))
                     {
                          index = i;
                     }
                } 
            }

            if(index != -1)
            {
                points.remove(index);
            }
        }
    }

}
公共类MapOverlay扩展了覆盖
{
私人阵列点;
...
@凌驾
公共布尔绘制(画布画布、地图视图、地图视图、布尔阴影、长时间)
{
super.draw(画布、地图视图、阴影);
int len=points.size();
如果(len>0)
{
对于(int i=0;i0)
{
对于(int i=0;i0)
{
对于(int i=0;i
(我没有在课堂上进行测试)

然后在MapActivity类中,您可以:

MapView mapView = (MapView) findViewById(R.id.mapview);
mapView.setClickable(true);
MapOverlay mapOverlay = new MapOverlay();                       
List<Overlay> listOfOverlays = mapView.getOverlays();
listOfOverlays.add(mapOverlay);
MapView MapView=(MapView)findViewById(R.id.MapView);
mapView.setClickable(真);
MapOverlay MapOverlay=新的MapOverlay();
List ListoForLays=mapView.getOverlays();
添加(映射覆盖);