Androidアプリを最新のGoogleMaps V2とともにMarshmallow 23にアップグレードしています。私がこれをした理由の1つは、最新のマップではマップ上に描画するもののZ-インデックスを設定できる.zIndexパラメータが許可されているからです。Googleマップ.zインデックスの問題
しかし私の問題は、コンパイラがaddMarkerステートメントのいくつかでは使えるが、他のステートメントでは使用できないということです。次のコードで
方法解決できないと言って.zIndexコンパイラフラグ:
private void addLegMarker(GoogleMap map, double lat, double lon,
String title, String snippet, float bearing)
{
//this method adds the permanent pin to the map and "moves" the arrow representing the target
//following two floats put the pin point exactly on the blue line
float u = (float) 0.2;
float v = (float) 1.0;
//following float center the arrow
float center = (float) 0.5;
//float myRotation = (float) 90.0;
//add the permanent pin to the location...
map.addMarker(new MarkerOptions().position(new LatLng(lat, lon))
.title(title)
.snippet(snippet)
.anchor(u, v))
.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.cpin)
.zIndex(1.0f)
);
if (!(lastArrowMarker == null))
{
lastArrowMarker.remove();
}
String ArrowSnippet = "Last known position of target phone";
lastArrowMarker = map.addMarker(new MarkerOptions()
.position(new LatLng(lat, lon))
.anchor(center, center)
.snippet(ArrowSnippet)
.rotation(bearing)
.icon(BitmapDescriptorFactory.fromResource(R.drawable.smallredarrow)
.zIndex(1.0f)
));
}
これは私のbuild.gradleファイルです:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
useLibrary 'org.apache.http.legacy' //httpClient not supported in 23.
defaultConfig {
applicationId "com.deanblakely.myappname"
minSdkVersion 16
targetSdkVersion 23
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile project(':library')
//compile project(':googleplayservices_lib')
compile files('libs/gson-2.2.4.jar')
compile 'com.android.support:appcompat-v7:23+'
compile 'com.android.support:design:23+'
//compile 'com.google.android.gms:play-services:9.4.0' too big. we just need maps and gcm
compile 'com.google.android.gms:play-services-maps:9.4.0'
compile 'com.google.android.gms:play-services-gcm:9.4.0'
}
をしかし、この次のコードは、.zIndexを受け入れますちょうどいいです:
私は気づいたところで、地図オブジェクトは引数として渡され、正常に動作している場合、コードはmapという名前のGoogleマップを直接参照しますが、どのように重要かはわかりません。
なぜコンパイラはこの1つのパラメータを1つの場所で受け入れ、別の場所にフラグを立てるのですか?
私は 'MarkerOptions'ドキュメントに' setIcon'メソッドがありません。それを 'icon'に変更すれば、何が起こるのですか? – nasch