简体   繁体   English

如何使用osmdroid在地图中心添加标记

[英]How do I add a marker on the center of the map using osmdroid

I am currently using 2 activities, the first will load the map and there will be a menu option called "add place" when this is clicked the user fills it in and then it is sent back to the main activity where it then adds a marker with this String. 我目前正在使用2个活动,第一个活动将加载地图,并且当用户单击该活动时,将有一个名为“添加地点”的菜单选项,然后将其发送回主活动,然后在该活动中添加标记与此字符串。 The problem is that I can only add a marker to a specific location where I define the latitude and longitude using GeoPoint. 问题是我只能将标记添加到使用GeoPoint定义纬度和经度的特定位置。 I want to be able to add the marker on the last location which the map was positioned. 我希望能够将标记添加到地图所定位的最后一个位置。 Could anyone give me any ideas as to how I could go about this? 谁能给我关于如何解决这个问题的任何想法?

You can get geopoint for current center of the map: 您可以获取地图当前中心的地理位置:

IGeoPoint point = mapView.getMapCenter()

And then use it for marker construction. 然后将其用于标记构建。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM