addMarker未显示Google地图选项

时间:2015-06-08 16:47:23

标签: java android google-maps

我正在使用asynctask查询我的数据库并填充包含两个双打的parcels对象的ArrayList,一个用于经度和纬度。

    ArrayList<parcels> mPoints = new ArrayList<parcels> ();

然而,当我添加我的标记时,没有显示任何显示我的所有调试消息,说明一切运行正常。但是当我看到我的地图上没有标记时。我是android的新手,也是java的新手。

    @Override
    protected void onPostExecute(String s) {
        super.onPostExecute(s);
        if(mPoints != null){
            //set points
            if(mMap == null){
                Log.d("JakeDebug", "map is null");


            }
            for(int i=0; i < mPoints.size(); i++){
                parcels tmp = mPoints.get(i);
                Log.d("JakeDebug", "marker at " + tmp.longitude +","+ tmp.latitude);
                mMap.addMarker(new MarkerOptions().position(new LatLng(tmp.latitude, -(tmp.longitude))).title(tmp.name).visible(true));
                //mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(tmp.latitude, tmp.longitude), 15));
                Log.d("JakeDebug", "Adding marker");

            }

        } else{
            Log.d("JakeDebug", " mPoints is null");


        }

我的输出调试:

06-08 09:41:39.599    3165-3182/teaminfamous.com.friendsend D/JakeDebug﹕ GetPackagesQuery:
06-08 09:41:39.720    3165-3182/teaminfamous.com.friendsend D/JakeDebug﹕ AddPackageQuery: just before query
06-08 09:41:39.720    3165-3182/teaminfamous.com.friendsend D/JakeDebug﹕ AddPackageQuery: query = "SELECT name, long, lat FROM _parcels_ where id=1"
06-08 09:41:39.728    3165-3182/teaminfamous.com.friendsend D/JakeDebug﹕ Login Query: empty = true
06-08 09:41:39.728    3165-3182/teaminfamous.com.friendsend D/JakeDebug﹕ just after query
06-08 09:41:40.337    3165-3165/teaminfamous.com.friendsend D/JakeDebug﹕ marker at 38.5539,121.7381
06-08 09:41:40.342    3165-3165/teaminfamous.com.friendsend D/JakeDebug﹕ Adding marker

1 个答案:

答案 0 :(得分:1)

在意识到我的数字被翻转然后放大后我看到标记时,你似乎必须放大到那个确切的位置!

 for(int i=0; i < mPoints.size(); i++){
                    parcels tmp = mPoints.get(i);
                    Log.d("JakeDebug", "marker at " + tmp.longitude +","+ tmp.latitude);
                    mMap.addMarker(new MarkerOptions().position(new LatLng(tmp.longitude, -(tmp.latitude))).title(tmp.name).visible(true));
                    mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(tmp.longitude, -(tmp.latitude)), 14));
                    Log.d("JakeDebug", "Adding marker");

                }

因此,如果您没有看到标记,请确保移动相机并放大它。这可能是问题所在,也确保您的号码在正确的顺序帮助!