{"id":117,"date":"2016-06-22T13:16:36","date_gmt":"2016-06-22T11:16:36","guid":{"rendered":"http:\/\/en.nisi.ro\/blog\/?p=117"},"modified":"2017-02-24T13:10:13","modified_gmt":"2017-02-24T11:10:13","slug":"android-draw-latlngbounds-on-a-googlemap-object","status":"publish","type":"post","link":"https:\/\/en.nisi.ro\/blog\/development\/java-android\/android-draw-latlngbounds-on-a-googlemap-object\/","title":{"rendered":"Android: draw LatLngBounds on a GoogleMap object"},"content":{"rendered":"<p>Quick question: If you have a LatLngBounds variable how to transform it to a polygon and draw it on a Google Map view in your Android Application?<\/p>\n<p>LatLngBounds store a rectangle by storing only 2 points from the rectangle the North East and South West, to build a new polygon you need the rest of the points.<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\n\r\n\r\n....\r\n@Override\r\npublic void onMapReady(GoogleMap googleMap) {\r\n   \/\/ get the bounds, for this example I will get the visible region on the google map view\r\n   LatLngBounds b = mapObj.getProjection().getVisibleRegion().latLngBounds;\r\n\r\n   PolygonOptions po = new PolygonOptions();\r\n\r\n   LatLng northwest = new LatLng(b.southwest.latitude, b.northeast.longitude);\r\n   LatLng southeast = new LatLng(b.northeast.latitude, b.southwest.longitude);\r\n\r\n   po.add(b.northeast, northwest);\r\n   po.add(northwest, b.southwest);\r\n   po.add(b.southwest, southeast);\r\n   po.add(southeast, b.northeast);\r\n\r\n   po.strokeColor(Color.RED);\r\n\r\n   googleMap.addPolygon(po);\r\n}\r\n...\r\n\r\n\r\n<\/pre>\n<ul>\n<li><a href=\"http:\/\/paydaysamedayloansonlineloan.accountant\">discover personal loan<\/a><\/li>\n<li><a href=\"http:\/\/speedycashpaydayloansonlinenet.accountant\">personal loan lenders<\/a><\/li>\n<li><a href=\"http:\/\/acecashexpresspaydayloansnocheck.accountant\">loan company<\/a><\/li>\n<li><a href=\"http:\/\/advanceamericapaydayloans.accountant\">apply for a loan<\/a><\/li>\n<li><a href=\"http:\/\/paydaymakemoneyfastnetcreditloansno.accountant\">secured credit cards for bad credit<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Quick question: If you have a LatLngBounds variable how to transform it to a polygon and draw it on a Google Map view in your Android Application? LatLngBounds store a rectangle by storing only 2 points from the rectangle the North East and South West, to build a new polygon you need the rest of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[21,132,133,134],"class_list":["post-117","post","type-post","status-publish","format-standard","hentry","category-java-android","tag-android-2","tag-google-maps","tag-latlngbounds","tag-polygon"],"_links":{"self":[{"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/posts\/117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/comments?post=117"}],"version-history":[{"count":2,"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/posts\/117\/revisions"}],"predecessor-version":[{"id":133,"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/posts\/117\/revisions\/133"}],"wp:attachment":[{"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/media?parent=117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/categories?post=117"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/tags?post=117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}