{"id":313,"date":"2023-05-17T15:26:01","date_gmt":"2023-05-17T15:26:01","guid":{"rendered":"https:\/\/itnotes.apjsoftwares.com\/?p=313"},"modified":"2023-05-17T15:26:01","modified_gmt":"2023-05-17T15:26:01","slug":"google-maps","status":"publish","type":"post","link":"https:\/\/itnotes.apjsoftwares.in\/index.php\/2023\/05\/17\/google-maps\/","title":{"rendered":"Google maps"},"content":{"rendered":"\n<p>Android allows us to integrate google maps in our application. You can show any location on the map , or can show different routes on the map e.t.c. You can also customise the map according to your choices.<\/p>\n\n\n\n<p><strong>Google Map &#8211; Layout file<\/strong><\/p>\n\n\n\n<p>Now you have to add the map fragment into the xml layout file. Its syntax is given below \u2212<\/p>\n\n\n\n<p>&lt;fragment<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;android:id=&#8221;@+id\/map&#8221;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;android:name=&#8221;com.google.android.gms.maps.MapFragment&#8221;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;android:layout_width=&#8221;match_parent&#8221;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;android:layout_height=&#8221;match_parent&#8221;\/&gt;<\/p>\n\n\n\n<p><strong>Google Map &#8211; AndroidManifest file<\/strong><\/p>\n\n\n\n<p>The next thing you need to do is to add some permissions along with the Google Map API key in the AndroidManifest.XML file. Its syntax is given below \u2212<\/p>\n\n\n\n<p>&lt;!&#8211;Permissions&#8211;&gt;<\/p>\n\n\n\n<p>&lt;uses-permission android:name=&#8221;android.permission.ACCESS_NETWORK_STATE&#8221; \/&gt;<\/p>\n\n\n\n<p>&lt;uses-permission android:name=&#8221;android.permission.INTERNET&#8221; \/&gt;<\/p>\n\n\n\n<p>&lt;uses-permission android:name=&#8221;com.google.android.providers.gsf.permission.<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;READ_GSERVICES&#8221; \/&gt;<\/p>\n\n\n\n<p>&lt;uses-permission android:name=&#8221;android.permission.WRITE_EXTERNAL_STORAGE&#8221; \/&gt;<\/p>\n\n\n\n<p>&lt;!&#8211;Google MAP API key&#8211;&gt;<\/p>\n\n\n\n<p>&lt;meta-data<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;android:name=&#8221;com.google.android.maps.v2.API_KEY&#8221;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;android:value=&#8221;AIzaSyDKymeBXNeiFWY5jRUejv6zItpmr2MVyQ0&#8243; \/&gt;<\/p>\n\n\n\n<p><strong>Customising Google Map<\/strong><\/p>\n\n\n\n<p>You can easily customise google map from its default view , and change it according to your demand.<\/p>\n\n\n\n<p><strong>Adding Marker<\/strong><\/p>\n\n\n\n<p>You can place a maker with some text over it displaying your location on the map. It can be done via addMarker() method. Its syntax is given below \u2212<\/p>\n\n\n\n<p>final LatLng TutorialsPoint = new LatLng(21 , 57);<\/p>\n\n\n\n<p><strong>Marker TP = googleMap.addMarker(new MarkerOptions()<\/strong><\/p>\n\n\n\n<p><strong>&nbsp;&nbsp;&nbsp;.position(TutorialsPoint).title(&#8220;TutorialsPoint&#8221;));<\/strong><\/p>\n\n\n\n<p><strong>Changing Map Type<\/strong><\/p>\n\n\n\n<p>You can also change the type of the MAP. There are four different types of map and each gives a different view of the map. These types are Normal,Hybrid,Satellite and terrain. You can use them as below<\/p>\n\n\n\n<p>googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);<\/p>\n\n\n\n<p>googleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);<\/p>\n\n\n\n<p>googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);<\/p>\n\n\n\n<p>googleMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN);<\/p>\n\n\n\n<p><strong>Enable\/Disable zoom<\/strong><\/p>\n\n\n\n<p>You can also enable or disable the zoom gestures in the map by calling the setZoomControlsEnabled(boolean) method. Its syntax is given below \u2212<\/p>\n\n\n\n<p>googleMap.getUiSettings().setZoomGesturesEnabled(true);<\/p>\n\n\n\n<p>Apart from these customization, there are other methods available in the GoogleMap class that help you customise the map. They are listed below \u2212<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>Sr.No<\/td><td>Method &amp; description<\/td><\/tr><tr><td>1<\/td><td>addCircle(CircleOptions options)This method add a circle to the map<\/td><\/tr><tr><td>2<\/td><td>addPolygon(PolygonOptions options)This method add a polygon to the map<\/td><\/tr><tr><td>3<\/td><td>addTileOverlay(TileOverlayOptions options)This method add tile overlay to the map<\/td><\/tr><tr><td>4<\/td><td>animateCamera(CameraUpdate update)This method Moves the map according to the update with an animation<\/td><\/tr><tr><td>5<\/td><td>clear()This method removes everything from the map.<\/td><\/tr><tr><td>6<\/td><td>getMyLocation()This method returns the currently displayed user location.<\/td><\/tr><tr><td>7<\/td><td>moveCamera(CameraUpdate update)This method repositions the camera according to the instructions defined in the update<\/td><\/tr><tr><td>8<\/td><td>setTrafficEnabled(boolean enabled)This method Toggles the traffic layer on or off.<\/td><\/tr><tr><td>9<\/td><td>snapshot(GoogleMap.SnapshotReadyCallback callback)This method Takes a snapshot of the map<\/td><\/tr><tr><td>10<\/td><td>stopAnimation()This method stops the camera animation if there is one in progress<\/td><\/tr><\/tbody><\/table><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Android allows us to integrate google maps in our application. You can show any location&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[9],"tags":[],"_links":{"self":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/313"}],"collection":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/comments?post=313"}],"version-history":[{"count":1,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/313\/revisions"}],"predecessor-version":[{"id":314,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/313\/revisions\/314"}],"wp:attachment":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/media?parent=313"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/categories?post=313"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/tags?post=313"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}