gpt4 book ai didi

android - 如何使用 osmdroid NominatimPOIProvider 获取靠近我的位置的一些 bus_stations

转载 作者:行者123 更新时间:2023-11-29 23:09:05 25 4
gpt4 key购买 nike

我正在尝试使用 osmdroid NominatimPOIProvider 获取靠近我的位置的一些 Bus_station,但我收到以下 NullException:

java.lang.IllegalArgumentException: south must be in [-85.05112877980658,85.05112877980658] at org.osmdroid.util.BoundingBox.set(BoundingBox.java:69).

我确定坐标没有任何点靠近我的位置

所以这是我实现逻辑的方法

 public  void poinOfInt(View view){

bus_stop = myLocationNewOverlay.getMyLocation();

NominatimPOIProvider poiProvider = new NominatimPOIProvider( BuildConfig.APPLICATION_ID);
ArrayList<POI> pois = poiProvider.getPOICloseTo(bus_stop, "highway", 50, 100);


FolderOverlay poiMarkers = new FolderOverlay();
map.getOverlays().add(poiMarkers);

Drawable poiIcon = getResources().getDrawable(R.drawable.marker_default);
for (POI poi:pois){
Marker poiMarker = new Marker(map);
poiMarker.setTitle(poi.mType);
poiMarker.setSnippet(poi.mDescription);
poiMarker.setPosition(poi.mLocation);
poiMarker.setIcon(poiIcon);
/* if (poi.mThumbnail != null){
poiItem.setImage(new BitmapDrawable(poi.mThumbnail));
}*/
poiMarkers.add(poiMarker);
}
}

我收到以下错误:

E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.xibomba, PID: 6617 java.lang.IllegalStateException: Could not execute method for android:onClick at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:390) at android.view.View.performClick(View.java:4754) at android.view.View$PerformClick.run(View.java:19605) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:146) at android.app.ActivityThread.main(ActivityThread.java:5752) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:385) at android.view.View.performClick(View.java:4754)  at android.view.View$PerformClick.run(View.java:19605)  at android.os.Handler.handleCallback(Handler.java:733)  at android.os.Handler.dispatchMessage(Handler.java:95)  at android.os.Looper.loop(Looper.java:146)  at android.app.ActivityThread.main(ActivityThread.java:5752)  at java.lang.reflect.Method.invokeNative(Native Method)  at java.lang.reflect.Method.invoke(Method.java:515)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)  at dalvik.system.NativeStart.main(Native Method)  Caused by: java.lang.IllegalArgumentException: south must be in [-85.05112877980658,85.05112877980658] at org.osmdroid.util.BoundingBox.set(BoundingBox.java:69) at org.osmdroid.util.BoundingBox.(BoundingBox.java:43) at org.osmdroid.bonuspack.location.NominatimPOIProvider.getUrlCloseTo(NominatimPOIProvider.java:73) at org.osmdroid.bonuspack.location.NominatimPOIProvider.getPOICloseTo(NominatimPOIProvider.java:132) at com.example.xibomba.MapaActivity.poinOfInt(MapaActivity.java:193) at java.lang.reflect.Method.invokeNative(Native Method)  at java.lang.reflect.Method.invoke(Method.java:515)  at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:385)  at android.view.View.performClick(View.java:4754)  at android.view.View$PerformClick.run(View.java:19605)  at android.os.Handler.handleCallback(Handler.java:733)  at android.os.Handler.dispatchMessage(Handler.java:95)  at android.os.Looper.loop(Looper.java:146)  at android.app.ActivityThread.main(ActivityThread.java:5752)  at java.lang.reflect.Method.invokeNative(Native Method)  at java.lang.reflect.Method.invoke(Method.java:515)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)  at dalvik.system.NativeStart.main(Native Method)

最佳答案

poiProvider.getPOICloseTo 方法的最后一个参数应该以度为单位(文档说:“到位置的最大距离,以度为单位。请注意,它用于在周围构建边界框位置,而不是圆圈。”)。您通过了 100,这是相当高的度数,所以您可能假设这些是公里或米。尝试较小的值,例如 0.10.2 或类似的值 as in examples .

关于android - 如何使用 osmdroid NominatimPOIProvider 获取靠近我的位置的一些 bus_stations,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56203601/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com