标记未出现在谷歌地图中



标记未出现在我的地图上。我在onMapReady类中编写了代码,但它仍然没有出现。有人能帮我吗?我无法解决这个问题。我试了很多次。

public class Home extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener, OnMapReadyCallback,
GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener,
LocationListener{
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
//Map
mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
//Add Marker
LatLng kilin = new LatLng(33.6518, 73.1566);
mMap.addMarker(new MarkerOptions().position(kilin).title("Stop")).setIcon(BitmapDescriptorFactory.fromResource(R.drawable.car));
}
}

您的代码应该可以工作,确保图标不是太小或透明或其他什么,也可以在添加标记后调用mMap.moveCamera(CameraUpdateFactory.newLatLng(kilin));,以确保您在正确的位置查找

相关内容

  • 没有找到相关文章

最新更新