{"id":618,"date":"2016-12-17T10:29:34","date_gmt":"2016-12-17T01:29:34","guid":{"rendered":"http:\/\/blue-bear.jp\/kb\/?p=618"},"modified":"2017-02-10T13:54:59","modified_gmt":"2017-02-10T04:54:59","slug":"android-googlemap-sdk%e3%81%a7%e7%b7%9apolyline%e3%82%92%e5%bc%95%e3%81%8f","status":"publish","type":"post","link":"https:\/\/blue-bear.jp\/kb\/android-googlemap-sdk%e3%81%a7%e7%b7%9apolyline%e3%82%92%e5%bc%95%e3%81%8f\/","title":{"rendered":"[android] GoogleMAP SDK\u3067\u7dda(PolyLine)\u3092\u5f15\u304f"},"content":{"rendered":"<h2>GoogleMAP SDK\u3067\u7dda(PolyLine)\u3092\u5f15\u304f<\/h2>\n<h3>GoogleMAP\u306ePolyLine\u306e\u5f15\u304d\u65b9<\/h3>\n<pre>\r\n@Override\r\npublic void onMapReady(GoogleMap googleMap) {\r\n    mMap = googleMap;\r\n    PolylineOptions rectOptions = new PolylineOptions()\r\n            .add(new LatLng(37.35, -122.0))\r\n            .add(new LatLng(37.45, -122.0))\r\n            .add(new LatLng(37.45, -122.2))\r\n            .add(new LatLng(37.35, -122.2))\r\n            .add(new LatLng(37.35, -122.0)); \r\n\r\n    Polyline polyline = mMap.addPolyline(rectOptions);\r\n}\r\n<\/pre>\n<p>\u3082\u3057\u304f\u306f<\/p>\n<pre>\r\nprivate ArrayList<LatLng> locationList;\r\n@Override\r\npublic void onMapReady(GoogleMap googleMap) {\r\n    mMap = googleMap;\r\n\r\n    locationList.add(new LatLng(37.35, -122.0));\r\n    locationList.add(new LatLng(37.45, -122.0));\r\n    locationList.add(new LatLng(37.45, -122.2));\r\n    locationList.add(new LatLng(37.35, -122.2));\r\n    locationList.add(new LatLng(37.35, -122.0));\r\n\r\n    PolylineOptions rectOptions = new PolylineOptions()\r\n            .addAll(locationList);\r\n    Polyline polyline = mMap.addPolyline(rectOptions);\r\n}\r\n<\/pre>\n<h3>PolyLine\u306e\u5e45\u3084\u8272\u306e\u5909\u66f4<\/h3>\n<p>.color\u3084.width\u3067PolyLine\u306e\u5e45\u3084\u8272\u306e\u5909\u66f4\u304c\u3067\u304d\u308b<\/p>\n<pre>\r\n    PolylineOptions rectOptions = new PolylineOptions()\r\n                .width(25)\r\n                .color(Color.BLUE)\r\n                .addAll(locationList);\r\n<\/pre>\n<h3>PolyLine\u306b\u8f2a\u90ed\u3092\u3064\u3051\u308b<\/h3>\n<p>\u4ee5\u4e0b\u306e\u69d8\u306b\uff12\u3064\u306ePolyLine\u3092\u91cd\u306d\u308b\u3053\u3068\u3067\u8f2a\u90ed\u304c\u3042\u308bPolyLine\u3092\u8868\u73fe\u3067\u304d\u308b<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blue-bear.jp\/kb\/wp-content\/uploads\/2016\/12\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2016-12-17-10.20.07.png\" alt=\"%e3%82%b9%e3%82%af%e3%83%aa%e3%83%bc%e3%83%b3%e3%82%b7%e3%83%a7%e3%83%83%e3%83%88-2016-12-17-10-20-07\" width=\"756\" height=\"836\" class=\"alignnone size-full wp-image-619\" srcset=\"https:\/\/blue-bear.jp\/kb\/wp-content\/uploads\/2016\/12\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2016-12-17-10.20.07.png 756w, https:\/\/blue-bear.jp\/kb\/wp-content\/uploads\/2016\/12\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2016-12-17-10.20.07-271x300.png 271w\" sizes=\"(max-width: 756px) 100vw, 756px\" \/><\/p>\n<pre>\r\nint strokeColor = ContextCompat.getColor(getActivity(), R.color.polylineStrokeColor);\r\n        int fillColor = ContextCompat.getColor(getActivity(), R.color.polylineFillColor);\r\n\r\n        int strokewidth = getResources().getInteger(R.integer.POLYLINE_STROKE_WIDTH_IN_PIXELS);\r\n        int fillwidth = getResources().getInteger(R.integer.POLYLINE_FILL_WIDTH_IN_PIXELS);\r\n\r\n        \/\/ stroke\u306b\u898b\u305b\u304b\u3051\u308bpolyline\u3092\u63cf\u753b\u3059\u308b\r\n        PolylineOptions strokeOptions = new PolylineOptions()\r\n                .width(strokewidth)\r\n                .color(strokeColor)\r\n                .addAll(positions);\r\n\r\n        \/\/ fill\u306b\u898b\u305b\u304b\u3051\u308bpolyline\u3092\u63cf\u753b\u3059\u308b\r\n        PolylineOptions fillOptions = new PolylineOptions()\r\n                \/\/ stroke\u306ewidth\u5206\u7d30\u3089\u305b\u3066\u3001stroke\u306b\u898b\u305b\u304b\u3051\u308bpolyline\u304c\u898b\u3048\u308b\u3088\u3046\u306b\u3059\u308b\r\n                .width(strokewidth - fillwidth*2)\r\n                .color(fillColor)\r\n                .addAll(positions);\r\n\r\n        googleMap.addPolyline(strokeOptions);\r\n        googleMap.addPolyline(fillOptions);\r\n<\/pre>\n<p>integar.xml<\/p>\n<pre>\r\n<resources>\r\n    <integer name=\"POLYLINE_STROKE_WIDTH_IN_PIXELS\">15<\/integer>\r\n    <integer name=\"POLYLINE_FILL_WIDTH_IN_PIXELS\">2<\/integer>\r\n<\/resources>\r\n<\/pre>\n<p>color.xml<\/p>\n<pre>\r\n<resources>\r\n    <color name=\"polylineFillColor\">#FF14a0ff<\/color>\r\n    <color name=\"polylineStrokeColor\">#FF000000<\/color>\r\n<\/resources>\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>GoogleMAP SDK\u3067\u7dda(Poly<\/p>\n","protected":false},"author":1,"featured_media":920,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24],"tags":[19],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts\/618"}],"collection":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/comments?post=618"}],"version-history":[{"count":3,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts\/618\/revisions"}],"predecessor-version":[{"id":622,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts\/618\/revisions\/622"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/media\/920"}],"wp:attachment":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/media?parent=618"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/categories?post=618"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/tags?post=618"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}