android 용 Google Maps API v3에서 길게 누르면 마커 추가를 구현하는 방법은 무엇입니까? Stack Overflow 자체에 대한 답변이 있지만 Google Maps API v2 용입니다. @tyczj는 지적Google지도 API v3의 길게 누르기에 마커 추가
public class advertiserMap extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_advertiser_map);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
//for searching for a location
public void onMapSearch(View view) {
EditText locationSearch = (EditText) findViewById(R.id.editText);
String location = locationSearch.getText().toString();
List<Address> addressList = null;
if (location != null || !location.equals("")) {
Geocoder geocoder = new Geocoder(this);
try {
addressList = geocoder.getFromLocationName(location, 1);
} catch (IOException e) {
e.printStackTrace();
}
Address address = addressList.get(0);
LatLng latLng = new LatLng(address.getLatitude(), address.getLongitude());
mMap.animateCamera(CameraUpdateFactory.newLatLng(latLng));
}
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// Add a marker in Sydney and move the camera
LatLng sydney = new LatLng(-34, 151);
mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
}
샘플 코드가 있습니까? –
v3과 같은 것은 존재하지 않으며, android는 v2입니다. https://developers.google.com/maps/documentation/android-api/start 앱에서 자바 버전 (v3)을 사용하고 싶지 않다면 – tyczj
@Drew 방금 방금 게시물을 편집했습니다 – jo12345678