Tag: android maps v2

在“LatLngBounds”构建器上设置最大缩放级别

我在搜索中没有find答案,所以有几个答案,但他们并没有为我工作。 我在地图上有两个标记,我正在使用LatLngBounds构建器,以便让相机缩放到正确的缩放级别以将它们包括在内。 一切都按预期工作,除了一个事情,当两个标记彼此非常接近时,地图非常放大而且很好,具有这个缩放级别没有任何意义。 LatLngBounds.Builder builder = new LatLngBounds.Builder(); builder.include(firstMarker.getPosition()); builder.include(secondMarker.getPosition()); LatLngBounds bounds = builder.build(); CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, markerPadding); 有没有办法强制一定程度的变焦,之后相机不会变焦? 这将避免让地图过于放大/缩小。 基本上我使用15.0f级别的缩放。 如果点太远,我想缩放以适应他们两个。 如果积分越来越近,我不希望缩放级别超过15.0f。

如何在模拟器上显示地图

从Android Studio开始,我创建了一个Map Activity项目; 所以,没有自定义代码。 唯一的自定义更改是复制google_maps_api.xml _( https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=) _中的url,并使用它创建API密钥。 Android Studio:3.0.1模拟器:带API 25的Nexus 5X Build.gradle文件 应用插件:’com.android.application’ 应用插件:’kotlin-android’ 应用插件:’kotlin-android-extensions’ android { compileSdkVersion 26 defaultConfig { applicationId“xxxx.xxx.xxxx” minSdkVersion 19 targetSdkVersion 26 versionCode 1 versionName“1.0” testInstrumentationRunner“android.support.test.runner.AndroidJUnitRunner” } buildTypes { 发布 { minifyEnabled false proguardFiles getDefaultProguardFile(’proguard-android.txt’),’proguard-rules.pro’ } } } 依赖{ 执行fileTree(dir:’libs’,include:[‘* .jar’]) 实施 “org.jetbrains.kotlin:科特林-STDLIB-jre7:$ kotlin_version” 实现’com.android.support:appcompat-v7:26.1.0′ 实现’com.google.android.gms:play-services-maps:11.0.0′ testImplementation’junit:junit:4.12′ androidTestImplementation’com.android.support.test:runner:1.0.1′ androidTestImplementation’com.android.support.test.espresso:espresso-core:3.0.1′ } […]