Google标记未显示在谷歌地图上

时间:2018-02-23 12:16:29

标签: android google-maps

我正在尝试学习谷歌地图,使用标签在谷歌地图中设置静态位置我可以看到地图和位置打印在日志中但标记没有显示。我在标记中也使用了visible(true)但它不起作用。这是我的代码

    mMapView.getMapAsync(new OnMapReadyCallback() {
        @Override
        public void onMapReady(GoogleMap gMap) {
            googleMap = gMap;
            googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
            try {
                googleMap.setMyLocationEnabled(true);
            } catch (SecurityException se) {
                Toast.makeText(self, "wdwdwqwdwdd", Toast.LENGTH_SHORT).show();
            }

            //Edit the following as per you needs
            googleMap.setTrafficEnabled(true);
            googleMap.setIndoorEnabled(true);
            googleMap.setBuildingsEnabled(true);
            googleMap.getUiSettings().setZoomControlsEnabled(true);


            // For dropping a marker at a point on the Map
            googleMap.addMarker(new MarkerOptions().position(SYDNEY).visible(true).title("Marker Title").snippet("Marker Description").icon(BitmapDescriptorFactory.fromResource(R.drawable.marker)));
            googleMap.addMarker(new MarkerOptions().position(PERTH).visible(true).title("Marker Title").snippet("Marker Description").icon(BitmapDescriptorFactory.fromResource(R.drawable.marker)));
            googleMap.addMarker(new MarkerOptions().position(BRISBANE).visible(true).title("Marker Title").snippet("Marker Description").icon(BitmapDescriptorFactory.fromResource(R.drawable.marker)));
            Log.i("lkfjdjdvdsvf", String.valueOf(SYDNEY));
            Log.i("lkfjdjdwdwdwdvdsvf", String.valueOf(PERTH));
            Log.i("lkfjdjdcacsacvdsvf", String.valueOf(BRISBANE));




            // For zooming automatically to the location of the marker
            CameraPosition cameraPosition = new CameraPosition.Builder().target(SYDNEY).zoom(12).build();
            googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));


        }
    });




    return view;

}

0 个答案:

没有答案