Then use getMapAsync to register for the map callback:. By default, the Maps SDK for Android displays the content of the info window when the user taps a marker. Learn more about the map object and what you can do with markers. Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 3.
For details, see our Site Policies. Last updated December 19, Bundle; import android. AppCompatActivity; import com. CameraUpdateFactory; import com.
GoogleMap; import com. OnMapReadyCallback; import com. SupportMapFragment; import com. LatLng; import com.
9.1: Adding a Google Map to your app
Download and install Android Studio. Add the Google Play services package to Android Studio. Import the tutorial project: Find the MapWithMarker project at this location: Android Studio now builds your project, using the Gradle build tool. Click the button below to get a key and activate the API. Add the API key to your app Edit your project's gradle.
Follow the instructions to enable developer options on your Android device and configure your system to detect the device. When choosing an emulator, make sure you pick an image that includes the Google APIs. For more details, see the getting started guide. In Android Studio, click the Run menu option or the play button icon. Choose a device as prompted. If you don't see a map, check that you've obtained an API key and added it to the app, as described above.
Use the Android Studio debugging tools to view logs and debug the app. Understand the code This part of the tutorial explains the most significant parts of the MapWithMarker app, to help you understand how to build a similar app. This guide is a quick start to adding a map to an Android app. Follow the guides to download and install Android Studio. Add Google Play services to Android Studio. Enter your app name, company domain, and project location, as prompted. Then click Next. Select the form factors you need for your app.
If you're not sure what you need, just select Phone and Tablet. Enter the activity name, layout name and title as prompted. The default values are fine. Then click Finish. Android Studio starts Gradle and builds your project. This may take a few seconds. For more information about creating a project in Android Studio, see the Android Studio documentation. Note that your activity may have a different name, but it will be the one you configured during setup. The next section describes getting the API key in more detail. The type of key you need is an API key with restriction for Android apps.
Customizing Google Map
The key is free. You can use it with any of your applications that call the Maps SDK for Android, and it supports an unlimited number of users. Examine the code supplied by the template. In particular, look at the following files in your Android Studio project. It contains the following code:.
By default, the Java file that defines the maps activity is named MapsActivity. It should contain the following code after your package name:. If your maps activity file doesn't contain the above code, replace the contents of the file with the above code, after your package name. The simplest way to see your app in action is to connect an Android device to your computer.
Follow the instructions to enable developer options on your Android device and configure your application and system to detect the device. Alternatively, you can use the Android Emulator to run your app. Use the Android Virtual Device AVD Manager to configure one or more virtual devices which you'll be able to use with the Android Emulator when you build and run your app.
When choosing your emulator, ensure that you use Android 4. Also, take note of the instructions for configuring virtual machine acceleration , which you should use with an x86 target AVD as described in the instructions. This will improve your experience with the emulator. In Android Studio, click the Run menu option or the play button icon to run your app.
Overview | Maps SDK for Android | Google Developers
Click OK. Android Studio will invoke Gradle to build your app, and then display the results on the device or on the emulator. It could take a couple of minutes before the app opens. You should see a map with a marker positioned over Sydney, Australia.
Adding a Map
If you don't see a map, confirm that you've completed all the steps described on this page. In particular, check that you've added an API key as described above. You may wish to look at some sample code. You can read more about map objects in the developer's guide.
- what the word answers phone bear!
- Step 2. Install the Google Play services SDK!
- free download dress up games for samsung mobile;
- Key developer features.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 3. For details, see our Site Policies.