2017-08-17 55 views
1

我如何限制Android谷歌地圖到一個城市?
我目前跟着代碼顯示谷歌地圖:如何限制Android谷歌地圖到一個城市?

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_maps); 
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() 
      .findFragmentById(R.id.map); 
    mapFragment.getMapAsync(this); 
} 

我想展示一個城市。任何方式?

+0

這是我的問題太... –

+0

的可能的複製[Android版谷歌地圖:禁用拖動在MapFragment(https://stackoverflow.com/questions/16979550/android-google-maps-disable-dragging -in-mapfragment) –

回答

1
private static final LatLngBounds DUBAI_BOUNDS = new LatLngBounds(new LatLng(24.5908366068, 54.84375), 
      new LatLng(25.3303729706, 55.6835174561)); 


map.setLatLngBoundsForCameraTarget(DUBAI_BOUNDS); 
2

使用公文 restrict the user's panning to a given area

來限制用戶。

更新的依賴關係爲自己的Play服務:

dependencies { 
    compile 'com.google.android.gms:play-services:9.6.1' 
} 
+0

嘿男人thx回答,但我想用戶不會到另一個位置,只是看到例如阿德萊德在地圖上,不能移動到另一個地方,只需放大和縮小阿德萊德。 – emen

相關問題