<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<fragment
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/map"
tools:context=".MainActivity"
android:name="com.google.android.gms.maps.SupportMapFragment"></fragment>
</LinearLayout>
package com.gmail.moontae0317.googlemapapitest
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
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.LatLng
import com.google.android.gms.maps.model.MarkerOptions
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity(),OnMapReadyCallback {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
var supportMapFragment = supportFragmentManager.findFragmentById(R.id.map) as SupportMapFragment
supportMapFragment.getMapAsync(this)
}
override fun onMapReady(p0: GoogleMap?) {
val mMap = p0
val latLng = LatLng(37.429253,126.699507)
var markerOptions = MarkerOptions()
markerOptions.position(latLng)
markerOptions.title("인천")
markerOptions.snippet("집")
mMap?.addMarker(markerOptions)
mMap?.moveCamera(CameraUpdateFactory.newLatLng(latLng))
mMap?.animateCamera(CameraUpdateFactory.zoomTo(10F))
}
}