에러가 뜨는데. 홈페이지를 봐도
package kr.co.company.mainactivity_map;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.widget.Toast;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
public class myact extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
private Marker markerS;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_myact);
// 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);
}
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or move the camera. In this case,
* we just add a marker near Sydney, Australia.
* If Google Play services is not installed on the device, the user will be prompted to install
* it inside the SupportMapFragment. This method will only be triggered once the user has
* installed Google Play services and returned to the app.
*/
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
LatLng Tokyo = new LatLng(35.6894875, 139.6917064);
mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL); // map type is normal
markerS = mMap.addMarker(new MarkerOptions().position(Tokyo).title("도쿄 지역입니다")
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));
mMap.moveCamera(CameraUpdateFactory.newLatLng(Tokyo));
mMap.setOnMarkerClickListener(new OnMarkerClickListener(){
@Override
public boolean onMarkerClick(Marker markerS) {
if (markerS.getTitle().equals("Click marker")) // if marker source is clicked
Toast.makeText(myact.this, markerS.getTitle(), Toast.LENGTH_SHORT).show();// display toast
return true;
}
});
}
}
에서 mMap.setOnMarkerClickListener()에서 괄호안에 new OnMarkerClickListener로 하면 에러가 뜨고 googlemap.하면 에러가 안뜨는데 실행후 마커를 누르면 아무것도 뜨질 않네요.. 마커클릭 인자를 markerS로 줬는데.. 초보개발 힘드네요. ㅠㅠ