2013-05-10 26 views
9
  • 如何創建標記類的實例,但不將其添加到地圖中。
+0

對於我創建的應用程序而言,這不僅僅是至關重要的。 – 2013-05-10 11:43:15

回答

4

您可以使用LazyMarker.javaAndroid Maps Extensions

直到你打電話給它setVisible(true)它不物理創建標記。

+0

它完成了這項工作。謝謝。 – 2013-05-10 12:14:16

3

您可以通過設置visibilityfalse

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; 
       } 
      }); 

,然後添加它,當你想這樣

做到這一點

希望它可以幫助

+0

這是一個選項,但仍然將標記實際添加到地圖中。我想知道是否有一種方法可以在不添加它的情況下創建它 - 比如Flex Maps API。 – 2013-05-10 11:47:09

+1

我認爲只能通過使用'com.google.android.gms.internal.z'創建一個新的'Marker'對象來完成'Marker m = new Marker(new z()/ *完全匿名的內部類* /)' – 2013-05-10 12:02:24

+1

@ AnujMathur_07標記構造函數不應該供開發人員使用,嘗試使用它不是好事。請參閱[此gmaps問題](http://code.google.com/p/gmaps-api-issues/issues/detail?id=5281)。 – 2013-05-10 12:07:57

相關問題