java – osm中的标记使用osmdroid进行映射
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了java – osm中的标记使用osmdroid进行映射,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3907字,纯文字阅读大概需要6分钟。
内容图文
![java – osm中的标记使用osmdroid进行映射](/upload/InfoBanner/zyjiaocheng/731/9b8a18c5dc2f482580a02ec2d46ae52f.jpg)
我试图在OSM中展示一个品牌,但不能.我可以显示OSM地图和手机的位置,但没有别的.
这是我的代码:
public class Carte2Activity extends Activity implements LocationListener {
MapView mapView;
MapController myMapController;
MyLocationOverlay location = null;
double lat;
double lng;
LocationManager lm;
LocationListener ll;
ArrayList<OverlayItem> anotherOverlayItemArray;
String[] sources;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mapView = (MapView)findViewById(R.id.openmapview);
mapView.setBuiltInZoomControls(true);
mapView.setMultiTouchControls(true);
lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
ll = new Myll();
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER,1000,0,ll);
myMapController = mapView.getController();
myMapController.setZoom(10);
myMapController.setCenter(new GeoPoint((int)(48.785152*1E6), (int)(2.285156*1E6)));
location = new MyLocationOverlay(getApplicationContext(), mapView);
//ajouter la loc
mapView.getOverlays().add(location);
//afficher
location.enableMyLocation();
}
private class Myll implements LocationListener{
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
lat = location.getLatitude();
lng = location.getLongitude();
run();
}
public void run() {
// TODO Auto-generated method stub
location.runOnFirstFix(new Runnable() { public void run() {
mapView.getController().animateTo(location.getMyLocation());
}});
}
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
}
}
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
}
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
}
}
androidManifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="comparateur.carte"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".Carte2Activity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
我不明白我该怎么做.有人能帮助我吗?
解决方法:
看看这些代码行:
OverlayItem myLocationOverlayItem = new OverlayItem("Here", "Current Position", currentLocation);
Drawable myCurrentLocationMarker = this.getResources().getDrawable(R.drawable.person);
myLocationOverlayItem.setMarker(myCurrentLocationMarker);
final ArrayList<OverlayItem> items = new ArrayList<OverlayItem>();
items.add(myLocationOverlayItem);
currentLocationOverlay = new ItemizedIconOverlay<OverlayItem>(items,
new ItemizedIconOverlay.OnItemGestureListener<OverlayItem>() {
public boolean onItemSingleTapUp(final int index, final OverlayItem item) {
return true;
}
public boolean onItemLongPress(final int index, final OverlayItem item) {
return true;
}
}, resourceProxy);
this.mapView.getOverlays().add(this.currentLocationOverlay);
我希望这能帮到您.
内容总结
以上是互联网集市为您收集整理的java – osm中的标记使用osmdroid进行映射全部内容,希望文章能够帮你解决java – osm中的标记使用osmdroid进行映射所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。