我可以更改位置,但地图不会移动

时间:2019-09-24 00:15:14

标签: android android-maps-v2

我可以更改位置,但地图不会移动。

当我尝试垂直或水平移动地图时,它会带我回到相同位置(NewDelhi)。我想移动地图并更改位置。

对于图像-> https://drive.google.com/open?id=1RTPJ7yKG2y4DLmmt-XECIa2vqqoaRZNS

我用于更改地图上位置的代码-

class myThred extends Thread
{


    public  void run()
    {

        while (true)
        {



            try {
                Thread.sleep(1000);



                runOnUiThread(new Runnable() {
                @Override
                public void run()
                {


                    map.clear();


                    if(locatioListinorEx.getLocation() != null)
                    {

                        // i can change location but  map is not moving
                        if(marker != null)
                        {
                            marker.remove();
                        }

                        LatLng NewDelhi = new LatLng(locatioListinorEx.getLocation().getLatitude(), locatioListinorEx.getLocation().getLongitude());
                        marker =  map.addMarker(new MarkerOptions()
                                .position(NewDelhi)
                                .title("NewDelhi")
                                .snippet("here i live")
                                .icon(BitmapDescriptorFactory.fromResource(R.drawable.ash)));

                        map.moveCamera(CameraUpdateFactory.newLatLngZoom(NewDelhi, 14));

                        for (int i = 0; i < listOfPockemon.size(); i++)
                        {
                            pockemon pockemon = listOfPockemon.get(i);

                            LatLng pockemonLocation =
                                    new LatLng(pockemon.location.getLatitude(), pockemon.location.getLongitude());
                            map.addMarker(new MarkerOptions()
                                    .position(pockemonLocation)
                                    .title(pockemon.name)
                                    .snippet(pockemon.dec + "\n" + "Power:" + pockemon.power))
                                    .setIcon(BitmapDescriptorFactory.fromResource(pockemon.image));


                        }


                    }

                }

                });


            }
            catch (Exception ex)
            {
            }
        }
    }

0 个答案:

没有答案