我正在尝试向我的Geoserver请求检索地图上用户点击附近的功能.

地图占据了所有空间.因此我用这种方式计算了BBOX:
region = mMap.getProjection().getVisibleRegion().latLngBounds;
double left = region.southwest.longitude;
double top = region.northeast.latitude;
double right = region.northeast.longitude;
double bottom = region.southwest.latitude;
Run Code Online (Sandbox Code Playgroud)
宽度和高度如下:
mMapFragment.getView().getWidth();
mMapFragment.getView().getHeight();
Run Code Online (Sandbox Code Playgroud)
而X和Y参数按以下方式计算:
Point click = mMap.getProjection().toScreenLocation(latLng);
Run Code Online (Sandbox Code Playgroud)
其中latLng是来自事件onMapClick(LatLng)的点(参考此处:https://developers.google.com/android/reference/com/google/android/gms/maps/GoogleMap.OnMapClickListener).
我获得的结果是:
http://localhost/geoserver/sindot/wms?service=WMS&request=GetFeatureInfo&info_format=application%2Fjson&version=1.1.1&srs=EPSG%3A3857&bbox=1222173.74033,5056403.44084,1222174.11356,5056403.7028&query_layers=sindot:verticale&layers=sindot:verticale&feature_count=3&styles=tabletb3lab&width=2048&height=1262&x=1441&y=503
Run Code Online (Sandbox Code Playgroud)
问题是服务器总是返回一个空响应,即使我知道那里有功能,因为我可以看到地图上的斑点.会是什么呢?
提前致谢.
前几天,我贴这个当您在屏幕多次相同的布局有关使用综合性能的问题。
答案很棒,但是在我尝试了几天之后,我注意到了一个奇怪的行为:
当从片段(包含对惰性委托获得的视图的引用的片段)前进然后返回(我使用transaction.commit()andmanager.popBackStack()来执行此操作)时,标签将为空。我已经用调试器检查过那里是否有任何内容为空,但什么都没有。
这似乎是工作的唯一解决办法是更换by lazy与lateinit var和分配他们onViewCreated。
你知道为什么吗?我使用的解决方案仍然“好”作为 kotlin 习语吗?
为了完整起见,我包含了两段代码:
部分工作之一:
private val foundTitle by lazy { detailContainer1.title }
private val foundDescription by lazy { detailContainer1.description }
private val wantedTitle by lazy { detailContainer2.title }
private val wantedDescription by lazy { detailContainer2.description }
Run Code Online (Sandbox Code Playgroud)
总是工作一个:
private lateinit var foundTitle: TextView
private lateinit var foundDescription: TextView
private lateinit var wantedTitle: TextView
private lateinit var wantedDescription: TextView
override fun onViewCreated(view: View, …Run Code Online (Sandbox Code Playgroud)