创build一个标记而不添加到地图?

  • 如何创build标记类的实例,但不添加到地图。

Solutions Collecting From Web of "创build一个标记而不添加到地图?"

您可以使用Android Maps Extensions中的 LazyMarker.java 。

在你调用setVisible(true)之前,它不会物理地创build标记。

您可以通过将visibility设置为false来执行此操作

 Marker marker = mMap.addMarker(new MarkerOptions() .position( new LatLng(arg0.latitude, arg0.longitude)) .draggable(true).visible(false)); 

编辑

 Marker m = new Marker(new z() { @Override public IBinder asBinder() { return null; } @Override public void showInfoWindow() throws RemoteException { } @Override public void setVisible(boolean paramBoolean) throws RemoteException { } @Override public void setTitle(String paramString) throws RemoteException { } @Override public void setSnippet(String paramString) throws RemoteException { } @Override public void setPosition(LatLng paramLatLng) throws RemoteException { } @Override public void setDraggable(boolean paramBoolean) throws RemoteException { } @Override public void remove() throws RemoteException { } @Override public boolean isVisible() throws RemoteException { return false; } @Override public boolean isInfoWindowShown() throws RemoteException { return false; } @Override public boolean isDraggable() throws RemoteException { return false; } @Override public void hideInfoWindow() throws RemoteException { } @Override public int hashCodeRemote() throws RemoteException { return 0; } @Override public String getTitle() throws RemoteException { return null; } @Override public String getSnippet() throws RemoteException { return null; } @Override public LatLng getPosition() throws RemoteException { return null; } @Override public String getId() throws RemoteException { return null; } @Override public boolean g(z paramz) throws RemoteException { return false; } }); 

然后添加它,当你想这样的

 mMap.addMarker(new MarkerOptions().position((m.getPosition()))); 

希望能帮助到你