相当蹩脚的标题,但这就是我想要弄清楚的。我只想能够在地图上长按创建标记,然后将这些标记保存在数据库、首选项、数组列表中,我不知道,只是在一些持久性存储中,它们不会在下次开始申请。我想保持简单,如果只是共享偏好,那么请告诉我如何。这是代码
public class MainActivity extends Activity implements ParsingCallback {
private GoogleMap mMap;
Marker marker = null;
String s;
GoogleMapOptions options;
LocationManager lm;
LatLng userLocation;
Location location;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
options = new GoogleMapOptions();
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
listOfPoints = new ArrayList<SavedMarkers>();
mMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
mMap.setMyLocationEnabled(true);
mMap.getUiSettings().setCompassEnabled(true);
mMap.getUiSettings().setRotateGesturesEnabled(true);
mMap.getUiSettings().setZoomGesturesEnabled(true);
mMap.getUiSettings().setMyLocationButtonEnabled(true);
}
/** On Map Long Click */
mMap.setOnMapLongClickListener(new OnMapLongClickListener() {
@Override
public void onMapLongClick(LatLng arg0) {
mMap.addMarker(new MarkerOptions().position(arg0).title(arg0.toString()));
Toast.makeText(getApplicationContext(), "Marker Created", Toast.LENGTH_SHORT).show();
}
});
}
}