public class MapViewer extends Activity implements OnInfoWindowClickListener {
private LatLng defaultLatLng = new LatLng(42.564241, 12.22759);
private GoogleMap map;
private int zoomLevel = 5;
private Database db = new Database(this);
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mapviewer);
try {
map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
if (map != null) {
map.setMyLocationEnabled(true);
map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
map.getUiSettings().setRotateGesturesEnabled(false);
map.moveCamera(CameraUpdateFactory.newLatLngZoom(defaultLatLng, zoomLevel));
this.addMerchantMarkers(new MarkerOptions());
map.setOnInfoWindowClickListener(this);
}
} catch (NullPointerException e) {
e.printStackTrace();
}
}
@Override
public void onPause() {
if (map != null) {
map.setMyLocationEnabled(false);
map.setTrafficEnabled(false);
}
super.onPause();
}
public void addMerchantMarkers(MarkerOptions mo) {
SQLiteDatabase dbRead = db.getReadableDatabase();
String[] columns = {"title", "addr", "lat", "lon"};
Cursor result = dbRead.query("merchants", columns, null, null, null, null, null);
while(result.moveToNext()) {
String merchant = result.getString(0);
String address = result.getString(1);
float lat = result.getFloat(2);
float lon = result.getFloat(3);
LatLng pos = new LatLng(lat, lon);
map.addMarker(mo.position(pos)
.title(merchant)
.snippet(address)
.icon(BitmapDescriptorFactory.fromResource(R.drawable.marker_50)));;
}
}
}
LatLngBounds.Builder builder = new LatLngBounds.Builder();
builder.include(new LatLng(47.09194444, 18.52166666));
builder.include(new LatLng(36.448311, 6.62555555));
LatLngBounds bounds = builder.build();
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, 30);
map.animateCamera(cu);
08-10 20:59:41.689: E/AndroidRuntime(6304): FATAL EXCEPTION: main
08-10 20:59:41.689: E/AndroidRuntime(6304): Process: com.example.myapp, PID: 6304
08-10 20:59:41.689: E/AndroidRuntime(6304): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapp/com.example.myapp.MapViewer}: java.lang.IllegalStateException: Error using newLatLngBounds(LatLngBounds, int): Map size can't be 0. Most likely, layout has not yet occured for the map view. Either wait until layout has occurred or use newLatLngBounds(LatLngBounds, int, int, int) which allows you to specify the map's dimensions.
08-10 20:59:41.689: E/AndroidRuntime(6304): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2215)
08-10 20:59:41.689: E/AndroidRuntime(6304): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2264)
08-10 20:59:41.689: E/AndroidRuntime(6304): at android.app.ActivityThread.access$800(ActivityThread.java:144)
08-10 20:59:41.689: E/AndroidRuntime(6304): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1205)
08-10 20:59:41.689: E/AndroidRuntime(6304): at android.os.Handler.dispatchMessage(Handler.java:102)
08-10 20:59:41.689: E/AndroidRuntime(6304): at android.os.Looper.loop(Looper.java:136)
08-10 20:59:41.689: E/AndroidRuntime(6304): at android.app.ActivityThread.main(ActivityThread.java:5139)
08-10 20:59:41.689: E/AndroidRuntime(6304): at java.lang.reflect.Method.invokeNative(Native Method)
08-10 20:59:41.689: E/AndroidRuntime(6304): at java.lang.reflect.Method.invoke(Method.java:515)
08-10 20:59:41.689: E/AndroidRuntime(6304): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:796)
08-10 20:59:41.689: E/AndroidRuntime(6304): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:612)
08-10 20:59:41.689: E/AndroidRuntime(6304): at dalvik.system.NativeStart.main(Native Method)
08-10 20:59:41.689: E/AndroidRuntime(6304): Caused by: java.lang.IllegalStateException: Error using newLatLngBounds(LatLngBounds, int): Map size can't be 0. Most likely, layout has not yet occured for the map view. Either wait until layout has occurred or use newLatLngBounds(LatLngBounds, int, int, int) which allows you to specify the map's dimensions.
08-10 20:59:41.689: E/AndroidRuntime(6304): at mut.b(Unknown Source)
08-10 20:59:41.689: E/AndroidRuntime(6304): at oxp.a(Unknown Source)
08-10 20:59:41.689: E/AndroidRuntime(6304): at oxi.a(Unknown Source)
08-10 20:59:41.689: E/AndroidRuntime(6304): at oyf.b(Unknown Source)
08-10 20:59:41.689: E/AndroidRuntime(6304): at grl.onTransact(SourceFile:92)
08-10 20:59:41.689: E/AndroidRuntime(6304): at android.os.Binder.transact(Binder.java:361)
08-10 20:59:41.689: E/AndroidRuntime(6304): at com.google.android.gms.maps.internal.IGoogleMapDelegate$a$a.animateCamera(Unknown Source)
08-10 20:59:41.689: E/AndroidRuntime(6304): at com.google.android.gms.maps.GoogleMap.animateCamera(Unknown Source)
08-10 20:59:41.689: E/AndroidRuntime(6304): at com.example.myapp.MapViewer.onCreate(MapViewer.java:59)
08-10 20:59:41.689: E/AndroidRuntime(6304): at android.app.Activity.performCreate(Activity.java:5231)
08-10 20:59:41.689: E/AndroidRuntime(6304): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
08-10 20:59:41.689: E/AndroidRuntime(6304): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2169)
08-10 20:59:41.689: E/AndroidRuntime(6304): ... 11 more
在科特林,这是对我有效的。
下面的代码,有时会给我抛出异常:
override fun onMapReady(googleMap: GoogleMap) {
mMap = googleMap
//mMap.uiSettings.isZoomControlsEnabled = true
mMap?.uiSettings?.isMyLocationButtonEnabled = true
mMap?.isMyLocationEnabled = true
val cameraUpdate = CameraUpdateFactory.newLatLngBounds(bounds, padding)
mMap?.animateCamera(cameraUpdate)
}
使用newLatLngBounds(LatLngBounds,int)时出错:映射大小不能为0。最有可能的是,地图视图的布局尚未发生。要么等待布局发生,要么使用newLatLngBounds(LatLngBounds,int,int,int),它允许您指定地图的尺寸
override fun onMapReady(googleMap: GoogleMap) {
mMap = googleMap
//mMap.uiSettings.isZoomControlsEnabled = true
mMap?.uiSettings?.isMyLocationButtonEnabled = true
mMap?.isMyLocationEnabled = true
mMap?.setOnMapLoadedCallback {
val cameraUpdate = CameraUpdateFactory.newLatLngBounds(bounds, padding)
mMap?.animateCamera(cameraUpdate)
}
}
我正在使用ApachePOI,发现当我使用HSSFRegionUtil向合并的单元格添加边框时,只会显示一个单元格的边框。 下面是代码 它只显示一个单元格的单元格边框,而不显示区域边框。感谢您的帮助。
问题内容: 我试图运行一个扩展的测试,但是运行时我得到了: 知道我缺少什么依赖性吗?我和jersey.version是2.5.1中包含以下球衣工件: 问题答案: 你需要: 从http://blog.dejavu.sk/2014/02/21/jersey-2-6-has-been-released-new-and- noteworthy/ Jersey,从JAX-RS 2.0的2.6版本和JAX-R
问题内容: 我将添加拉动以刷新我的Web视图,以便刷新我的Web视图。我已经看到了此页面上的所有问题,但我找不到添加拉动刷新的好方法… Mainactivity.java content_main.xml 我希望任何人都能帮助我并为我解决这个问题。 问题答案: 您可以像这样在Swipe Refesh布局中包装webview 在java中
问题内容: 我想用datatyp uint8添加numpy数组。我知道这些数组中的值可能足够大,以至于发生溢出。所以我得到类似: 现在,a是。但是,我希望让uint8太大的值成为uint8允许的最大值,而不是溢出。所以我想要的结果是。 我可以使用以下代码获得此结果: 问题是我的数组很大,因此创建具有更大数据类型的第三个数组可能是内存问题。是否有一种快速且更节省内存的方式来实现上述结果? 问题答案:
我有以下实体: 我尝试过创建@OneToOne(FetchType.lazy),但不起作用,它仍然提取不需要的信息。 如何避免获取复合对象? 我希望最终结果不包含Address对象,因为它在20个场景中需要一次,我可以分别获取它们。 任何想法,如何实现这一点。 谢谢
请帮助我如何找到两个矩形区域之间的交点。 例如:我在virtual earth MapsV6.3中搜索可视区域的结果 地图返回给我左上和右下的点作为纬度和经度。然后我平移区域移动到不同的位置。我有我的旧坐标保存现在我想找到共同的区域之间的旧的可视区域和新的可视区域。我已经有左上和右下的点了。