我正在尝试在android studio中实现OpenStreetMap。我成功添加了库,如下所示。
这是我的MainActivity:
$("#optionNetFlow")[0].selectize.clear();
这是我的build.gradle文件:
package com.example.re.osm;
import org.osmdroid.views.MapController;
import org.osmdroid.views.MapView;
import android.app.Activity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.example.harjotkaur.osm.R;
public class MainActivity extends Activity {
private MapView myOpenMapView;
private MapController myMapController;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myOpenMapView = (MapView)findViewById(R.id.openmapview);
myOpenMapView.seharjotkaurtBuiltInZoomControls(true);
myMapController = myOpenMapView.getController();
myMapController.setZoom(4);
}
}
这是我的清单文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.example.re.osm"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile files('libs/slf4j-android-1.5.8.jar')
compile files('libs/osmdroid-android-3.0.8.jar')
}
但是当我运行应用程序时,我只能看到小矩形,而不是地图。 我该怎么解决这个问题?我应该遵循哪些步骤?
任何想法都表示赞赏?
由于
答案 0 :(得分:1)
替换
import com.exercise.OpenStreetMapView.R;
用这个:
import com.example.re.osm.R;