This location in the built-in storage is the best place for your maps. On your Android phone or tablet, open the Google Maps app. Tap your profile picture or initial Offline maps. You can select your own map to download, or view maps you've already downloaded. Google takes abuse of its services very seriously. We're committed to dealing with such abuse according to the laws in your country of residence.
When you submit a report, we'll investigate it and take the appropriate action. Latest version. Oct 30th, Older versions. Google Maps is available on Android and offers all the usual features of the Google service, plus the addition of a GPS feature which makes it impossible to get lost in a big city.
To start, tap the hamburger icon in the top-left corner of Google Maps, then choose "Offline maps" Android or "Offline areas" iPhone. Here is where you name your app and create the package based on your domain. Here are the settings for an app called Current Place, which corresponds to the package com.
Android Studio projects typically have two build. One is for the overall project and one is for the app. You need to edit the build. If you do not already have a Google Cloud Platform account and a project with billing enabled, please see the Getting Started with Google Maps Platform guide to create a billing account and a project.
Copy the API key you just created. To give the user a button to click when they want to pick their current place, add an app bar with an icon that finds the user's current place and displays nearby likely places. It will look like this:. The my location icon is the same as the one used in the Google Maps app when a user wants to snap the camera to their current location.
The first line is used in your app bar when there is space to include a text label next to the icon. The others are used for markers that you add to the map. Add these lines at the top of MapsActivity.
It replaces the FragmentActivity extension that is defined by default for a maps activity. Next, declare the various class variables used in different class methods.
These include the UI elements and status codes. These should be just below the variable declaration for GoogleMap mMap. You'll need to update the onCreate method to handle runtime user permissions for location services, setting up the UI elements and creating the Places API client. Add the following lines of code regarding the action toolbar, views setup, and Places client to the end of the existing onCreate method. These two methods add the app bar menu with a single item, the Pick Place icon and handle the user's click on the icon.
Copy these two methods into your file after the onCreate method. After a few moments, the app launches. You see the map centered on Sydney, Australia, with the single button and unpopulated places list. The focus of the map doesn't move to the user's location unless you request permission to access the device's location. Paste this code below the onOptionsSelected method you just created.
When the user clicks Pick Place in the app bar, the app calls the method pickCurrentPlace , which calls the getDeviceLocation method you defined earlier. The getDeviceLocation method calls another method, getCurrentPlaceLikelihoods, after retrieving the latest device location.
If the task is successful, it returns a findCurrentPlaceResponse , which contains a list of placeLikelihood objects. Each of these have a number of properties, including the name and address of the place, and the likelihood probability that you are in that place a double value from 0 to 1. This method handles the response by constructing lists of place details from the placeLikelihoods. This code iterates through the five most-likely places and adds ones with a likelihood grater than 0 to a list which it then rendera.
If the user grants permission, the app fetches the user's latest location and moves the camera to center around that location. If the user denies permission, the app simply moves the camera to the default location defined among the constants at the beginning of this page in the sample code, it is Sydney, Australia. When the user taps Pick Place , this method checks for location permissions and prompts the user for permission if it hasn't been granted. If the user has granted permission, then the method calls getDeviceLocation to initiate the process of getting the current likely places.
If you run the app now and tap Pick Place , it should prompt for location permissions. Let's think about what we want to happen when the user clicks an item in the ListView. To confirm the user's choice of which place they are currently, you can add a marker to the map at that place.
If the user clicks that marker, an info window pops up displaying the place name and address. Paste this click handler after the pickCurrentPlace method. Now that you have your list of most-likely places that the user is currently visiting, you can present those options to the user in the ListView.
Now that fillPlacesList is defined, find the line toward the end of findPlaceLikelihoods that calls fillPlacesList and uncomment it. This time when you tap Pick Place , the app populates the list with named places close to the location. Because the several places are very close to the location coordinates, this is a list of likely places you may be in.
If you want to change your location and are using the emulator, the device location doesn't automatically update when you update the location coordinates in the emulator's extended menu. To get around this, follow these steps to use the native Google Maps app to force updates to the emulator's location:. And that's it! You built a simple app that checks for the places at the current location and gives you a likelihood of which ones you're at.
To prevent theft of your API key, you need to secure it so only your Android app can use the key. If left unrestricted, anyone with your key could use it to call Google Maps Platform APIs and cause you to get billed.
You need this later when you restrict your API keys. The following is a set of instructions for getting your debug certificate. The fingerprint is the sequence of 20 double-digit hexadecimal numbers separated by colons. When you are ready to release an app, use the instructions in this documentation to retrieve your release certificate. You built a simple app that checks for the most-likely places at the current location and adds a marker to the map for the place the user selects.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4. For details, see the Google Developers Site Policies. Use location permissions to geolocate the user. Fetch Places near the user's current location. Present likely Places to the user to identify their current location.
What you'll build You build your Android app from scratch, but you can download the sample code for comparison when debugging. This lab was written using Android Studio 3. Select your desired SDK checkbox, then click Apply. Update if the status reads Update available. Prepare the emulator To run the app, you can connect your own device or use the Android Emulator. This opens the Android Virtual Device Manager dialog.
Click Create Virtual Device Choose a device with the Play icon in the Play Store column and click Next. Map downloads use a lot of data so it's best to download maps when connected to Wi-Fi. Enable saving to your SD card optional.
Downloaded maps will save to your internal memory by default, which is fine if you have a lot of internal memory. As long as you've already formatted your SD card as Portable Storage , you can opt to save maps to it instead. Type a city or location into the search bar.
If you want your map to encompass more than one city, you'll be able to expand the area in a little bit. Just start with one city or location for now. If you prefer, you can select a location visually on the map. Skip down to step 7 for the remaining steps. The map will zoom in to the selected location.
Tap the name of the place. It's near the bottom of the screen. Some more options will appear. Drag the box to select the area you want to download. The area within the confines of the box will be downloaded to your phone or tablet for offline use. You can capture more or less of the selected area by zooming in or out. Pinch two fingers together on the screen to zoom out, or reverse-pinch to zoom in. It's at the bottom of the screen. The selected map area will now download to your Android.
Google Maps will continue using your mobile data plan whenever a connection is available. Though you can still get driving directions when you're offline, you won't be able to get public transit, walking, or biking directions. Method 2. It's the multicolored map icon with a red pushpin. You'll usually find it on the home screen.
Tap the Search key. It's near the top-right corner. Tap Download offline map. You'll see a box surrounding a suggested download area. The selected map area will now download to your iPhone or iPad.
If you want to force Google Maps to use your downloaded map instead, you must disconnect from your mobile data plan. You can toggle mobile data on and off by swiping up from the bottom of the home screen and tapping the antennae icon to the right of the airplane.
Method 3. Though there's no way to download a map area when you're using a computer, you can download directions in advance and save them to a PDF file. Type your destination into the Search bar. If you want to save directions to a location, type the address or name of that location into this box. As you type, a list of matching results will appear. Click the location in the search results. The map will zoom in to the location.
0コメント