如何将指针放在地图上?

时间:2014-04-15 07:49:15

标签: android

我的问题是我有一个恒定的地理位置,我想找到半径不到500米的位置 从我的常量geo point。我们可以找到这些位置并保存在SharedPreferences中。

1 个答案:

答案 0 :(得分:0)

你的问题很模糊,但我会尽力帮助你。

如果您使用的是地图v2,则这是添加标记的一种方法:

 myMap.addMarker(new MarkerOptions()
                 .position(mGeoPoint)
                 .icon(BitmapDescriptorFactory
                       .fromResource(R.drawable.yourmarkericon)));

myMap是Map V2,GeoPoint应该是LatLng值:

 double latitude = 2.344343;
 double longitude = 45.203922;
 mGeoPoint = new LatLng (latitude, longitude);

要在共享偏好设置中保存地理位置,您可以使用:

 SharedPreferences myPrefs = getSharedPreferences(MyPrefs, Context.MODE_PRIVATE);
 Editor editor = myPrefs.edit();
 editor.putLong("GeoPoint_LAT", (long) latitude);
 editor.putLong("GeoPoint_LNG", (long) longitude);
 editor.commit();

希望它有所帮助。