Aug 24, 2019 HERE WeGo Maps. Price: Free HERE WeGo is one of only a few serious competitors to Google Maps in the navigation app space. It features a simple, elegant interface with mapping options all over the. On your Android phone or tablet, open the Google Maps app. Make sure you're connected to the internet and signed in to Google Maps. Search for a place, like San Francisco. Before you use this mode, make sure you download offline maps. To turn on this mode, open the Google Maps app Menu next to 'Wi-Fi only,' turn the switch on. Google maps free download - maps google browser, Google Maps Go, Google My Maps, and many more programs.
Samples demonstrating how to useGoogle Maps Platform SDK for Android v2.
This repo contains the following samples:
Pre-requisites
See each sample for pre-requisites.All require an uptodate version of the Android build tools and the Android support repository.
Getting Started
These samples use the Gradle build system.
First download the samples by cloning this repository or downloading an archivedsnapshot. (See the options at the top of the page.)
In Android Studio, use the 'Import non-Android Studio project' or'Import Project' option. Next select one of the sample directories that you downloaded from thisrepository.If prompted for a gradle configuration accept the default settings.
Alternatively use the 'gradlew build' command to build the project directly.
Add your API key to the
AndroidManifest.xml file.See the quick guide to getting an API key.
Support
If you have discovered an issue with the Google Maps Platform SDK for Android v2, please seethe resources here: https://developers.google.com/maps/support/
If you've found an error in these samples, please file an issue:https://github.com/googlemaps/android-samples/issues
Patches are encouraged, and may be submitted according to the instructions inCONTRIBUTING.md.
License
(See each sample directory for details.)
Copyright 2015 The Android Open Source Project
Copyright 2015 Google, Inc.
Licensed to the Apache Software Foundation (ASF) under one or more contributorlicense agreements. See the NOTICE file distributed with this work foradditional information regarding copyright ownership. The ASF licenses thisfile to you under the Apache License, Version 2.0 (the 'License'); you may notuse this file except in compliance with the License. You may obtain a copy ofthe License at
Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an 'AS IS' BASIS, WITHOUTWARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See theLicense for the specific language governing permissions and limitations underthe License.
-->
Using the Maps application is great, but sometimes you want to includemaps directly in your application. In addition to the built-in mapsapplication, Google also offers anative mapping API for Android.The Maps API is suitable for cases where you want to maintain morecontrol over the mapping experience. Things that are possible with theMaps API include:
Unlike the now-deprecated Google Maps Android API v1, Google MapsAndroid API v2 is part ofGoogle Play Services.A Xamarin.Android app must meet some mandatory prerequisites beforeit is possible to use the Google Maps Android API.
Google Maps API prerequisites
Several steps need to be taken before you can use the Maps API, including:
Obtain a Google Maps API Key
The first step is to get a Google Maps API key (note that you cannotreuse an API key from the legacy Google Maps v1 API). For information abouthow to obtain and use the API key with Xamarin.Android, seeObtaining A Google Maps API Key.
Install the Google Play Services SDK
Google Play Services is a technology from Google that allows Androidapplications to take advantage of various Google features such asGoogle+, In-App Billing, and Maps. These features are accessible onAndroid devices as background services, which are contained in theGoogle Play Services APK.
Android applications interact with Google Play Services through theGoogle Play Services client library. This library contains theinterfaces and classes for the individual services such as Maps. Thefollowing diagram shows the relationship between an Android applicationand Google Play Services:
The Android Maps API is provided as a part of Google Play Services.Before a Xamarin.Android application can use the Maps API, the GooglePlay Services SDK must be installed using the Android SDK Manager. The followingscreenshot shows where in the Android SDK Manager the Google Playservices client can be found:
Note
The Google Play services APK is a licensed productthat may not be present on all devices. If it is not installed, thenGoogle Maps will not work on the device.
Install the Xamarin.GooglePlayServices.Maps package from NuGet
The Xamarin.GooglePlayServices.Maps package contains the Xamarin.Android bindings for the Google Play Services Maps API.To add the Google Play Services Map package, right-click theReferences folder of your project in the Solution Explorer andclick Manage NuGet Packages..:
This opens the NuGet Package Manager. Click Browse and enterXamarin Google Play Services Maps in the search field. SelectXamarin.GooglePlayServices.Maps and click Install. (Ifthis package had been installed previously, click Update.):
Notice that the following dependency packages are also installed:
Specify the required permissions
Apps must identify the hardware and permission requirements in order to use the Google Maps API. Some permissions are automatically granted by the Google Play Services SDK, and it is not necessary for a developer to explicitly add them to AndroidManfest.XML:
The following permissions and features must be specified in theAndroidManifest.XML for the Google Maps Android API:
In addition, Android 9 has removed the Apache HTTP client library from the bootclasspath, and so it isn't available to applications that target API 28 or higher. The following line must be added to the
application node of your AndroidManifest.xml file to continue using the Apache HTTP client in applications that target API 28 or higher:
Note
Very old versions of the Google Play SDK required an app to request the
WRITE_EXTERNAL_STORAGE permission. This requirement is no longer necessary with the recent Xamarin bindings for Google Play Services.
The following snippet is an example of the settings that must be added to AndroidManifest.XML:
In addition to requesting the permissions AndroidManifest.XML, an app must also perform runtime permission checks for the
ACCESS_COARSE_LOCATION and the ACCESS_FINE_LOCATION permissions. See the Xamarin.Android Permissions guide for more information about performing run-time permission checks.
Create an Emulator with Google APIs
In the event that a physical Android device with Google Play services is not installed, it is possible to create an emulator image for development. For more information see the Device Manager.
The GoogleMap Class
Once the prerequisites are satisfied, it is time to startdeveloping the application and use the Android Maps API. TheGoogleMapclass is the main API that a Xamarin.Android application will use todisplay and interact with a Google Maps for Android. This class has thefollowing responsibilities:
The
GoogleMap is added to an Activity in one of two ways:
Each of these containers exposes a
Map property that returns aninstance of GoogleMap . Preference should be given to theMapFragmentclass as it is a simpler API that reduces the amount boilerplate codethat a developer must manually implement.
Adding a MapFragment to an Activity
The following screenshot is an example of a simple
MapFragment :
Similar to other Fragment classes, there are two ways to add a
MapFragment to an Activity:
The
MapFragment.GetMapAsync method is used to initialize the GoogleMap that is hosted by the fragment and obtain a reference to the map object that is hosted by the MapFragment . This method takes an object that implements the IOnMapReadyCallback interface.
This interface has a single method,
IMapReadyCallback.OnMapReady(MapFragment map) that will be invoked when it is possible for the app to interact with the GoogleMap object. The following code snippet shows how an Android Activity can initialize a MapFragment and implement the IOnMapReadyCallback interface:
Map types
There are five different types of maps available from the Google MapsAPI:
The image below shows three of the different types of maps, fromleft-to-right (normal, hybrid, terrain):
The
GoogleMap.MapType property is used to set or change which type ofmap is displayed. The following code snippet shows how to display asatellite map.
GoogleMap propertiesGoogleMap defines several properties that can control the functionalityand the appearance of the map. One way to configure the initial stateof a GoogleMap is to pass aGoogleMapOptionsobject when creating a MapFragment . The following code snippet is oneexample of using a GoogleMapOptions object when creating a MapFragment :
The other way to configure a
GoogleMap is by manipulating properties on theUiSettingsof the map object. The next code sample shows how to configure aGoogleMap to display the zoom controls and a compass:
Interacting with the GoogleMap
The Android Maps API provides APIs that allow an Activity to changethe viewpoint, add markers, place custom overlays, or draw geometricshapes. This section will discuss how to accomplish some of these tasksin Xamarin.Android.
Changing the Viewpoint
Maps are modelled as a flat plane on the screen, based on the Mercatorprojection. The map view is that of a camera looking straight down onthis plane. The position of the camera can be controlled by changingthe location, zoom, tilt, and bearing. TheCameraUpdateclass is used to move the camera location.
CameraUpdate objects are notdirectly instantiated, instead the Maps API provides theCameraUpdateFactoryclass.
Once a
CameraUpdate object has been created, it is passed as aparameter to either theGoogleMap.MoveCameraorGoogleMap.AnimateCameramethods. The MoveCamera method updates the map instantly while theAnimateCamera method provides a smooth, animated transition.
This code snippet is a simple example of how to use the
CameraUpdateFactory to create a CameraUpdate that will incrementthe zoom level of the map by one zoom level:
The Maps API provides aCameraPositionwhich will aggregate all of the possible values for the cameraposition. An instance of this class can be provided to theCameraUpdateFactory.NewCameraPositionmethod which will return a
CameraUpdate object. The Maps API alsoincludes theCameraPosition.Builderclass that provides a fluent API for creating CameraPosition objects.The following code snippet shows an example of creating a CameraUpdate from a CameraPosition and using that to change the camera position on aGoogleMap :
In the previous code snippet, a specific location on the map isrepresented by theLatLngclass. The zoom level is set to 18, which is an arbitrary measure of zoom used by Google Maps. The bearing is the compassmeasurement clockwise from North. The Tilt property controls theviewing angle and specifies an angle of 25 degrees from thevertical. The following screenshot shows the
GoogleMap after executingthe preceding code:
Drawing on the Map
The Android Maps API provides API's for drawing the following items on a map:
Markers
The Maps API provides aMarkerclass which encapsulates all of the data about a single location on amap. By default the Marker class uses a standard icon provided by Google Maps. It ispossible to customize the appearance of a marker and to respond to userclicks.
Adding a Marker
To add a marker to a map, it is necessary create a newMarkerOptions object and then call theAddMarkermethod on a
GoogleMap instance. This method will return aMarkerobject.
The title of the marker will be displayed in an info window when theuser taps on the marker. The following screenshot shows what thismarker looks like:
Customizing A MarkerDownload Application For Android
It is possible to customize the icon used by the marker by calling the
MarkerOptions.InvokeIcon method when adding the marker to the map.This method takes aBitmapDescriptorobject containing the data necessary to render the icon. TheBitmapDescriptorFactoryclass provides some helper methods to simplify the creation of aBitmapDescriptor . The following list introduces some of these methods:
The following code snippet shows an example of creating a cyan coloureddefault marker:
Info windows
Info windows are special windows that popup to display information tothe user when they tap a specific marker. By default the info windowwill display the contents of the marker's title. If the title has notbeen assigned, then no info window will appear. Only one info windowmay be shown at a time.
It is possible to customize the info window by implementing theGoogleMap.IInfoWindowAdapterinterface. There are two important methods on this interface:
An info window is not a live view - instead Android will convert theView to a static bitmap and display that on the image. This means thatan info window cannot respond to any touch events or gestures, nor willit automatically update itself. To update an info window, it isnecessary to call theGoogleMap.ShowInfoWindowmethod.
The following image shows some examples of some customized infowindows. The image on the left has its contents customized, while theimage on the right has its window and contents customized with rounded corners:
Google Maps Application For Android Download Windows 7GroundOverlays
Unlike markers, which identify a specific location on a map, aGroundOverlayis an image that is used to identify a collection of locations or an areaon the map.
Adding a GroundOverlay
Adding a ground overlay to a map is similar to adding a marker toa map. First, aGroundOverlayOptionsobject is created. This object is then passed as a parameter to the
GoogleMap.AddGroundOverlay method, which will return aGroundOverlay object. This code snippet is an example of adding aground overlay to a map:
The following screenshot shows this overlay on a map:
Lines, Circles, and Polygons
There are three simple types of geometric figures that can be added to a map:
Free Application For Android PhonesPolylines
A Polylineis a list of consecutive
LatLng objects which specify the vertices ofeach line segment. A polyline is created by first creating aPolylineOptions object and adding the points to it. ThePolylineOption object is then passed to a GoogleMap object by callingthe AddPolyline method.
Circles
Circles are created by first instantiating aCircleOptionobject which will specify the center and the radius of the circle inmetres. The circle is drawn on the map by callingGoogleMap.AddCircle.The following code snippet shows how to draw a circle:
PolygonsPolygon s are similar to Polyline s, however they are not openended. Polygon s are a closed loop and have their interior filled in.Polygon s are created in the exact same manner as a Polyline , except theGoogleMap.AddPolygonmethod invoked.
Unlike a
Polyline , a Polygon is self-closing. The polygon will be closed off by the AddPolygon method by drawing a line which connects the first and last points. The following codesnippet will create a solid rectangle over the same area as theprevious code snippet in the Polyline example.
Responding to user events
There are three types of interactions a user may have with a map:
Each of these events will be discussed in more detail below.
Marker click events
The
MarkerClicked event is raised when the user taps on a marker. This event accepts a GoogleMap.MarkerClickEventArgs object as a parameter. This classcontains two properties:
This code snippet shows an example of a
MarkerClick that will changethe camera position to a new location on the map:
Marker Drag events
This event is raised when the user wishes to drag the marker. Bydefault, markers are not draggable. A marker can be set as draggable bysetting the
Marker.Draggable property to true or by invoking theMarkerOptions.Draggable method with true as a parameter.
To drag the marker, the user must first long-click on the marker and then their finger must remain on the map. When the user's finger is dragged around on the screen, themarker will move. When the user's finger lifts off the screen, themarker will remain in place.
The following list describes the various events that will be raisedfor a draggable marker:
Each of the
EventArgs contains a single property called P0 that is areference to the Marker object being dragged.
![]() Info Window Click events
Only one info window can be displayed at a time. When the user clickson an info window in a map, the map object will raise an
InfoWindowClick event. The following code snippet shows how to wireup a handler to the event:
Recall that an info window is a static
View which is rendered as animage on the map. Any widgets such as buttons, check boxes, or textviews that are placed inside the info window will be inert and cannotrespond to any of their integral user events.
Related LinksComments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |