11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
203 |
--------------------------------------------------------------------------------
/MarkerBuilder.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # MarkerBuilder
2 | Versatile map area / geofence utility for google maps v2 for android.
3 | Create geofence areas in your map by initializing markerBuilderManager.
4 | Not that difficult isn't it?
5 |
6 | 
7 |
8 | Usage
9 | ------
10 | ```java
11 | private void setUpMap() {
12 | markerBuilderManager = new MarkerBuilderManagerV2.Builder(this)
13 | .map(mMap) // required
14 | .build();
15 | }
16 | ```
17 |
18 | You can also set other marker options such as:
19 | ```java
20 | markerBuilderManager = new MarkerBuilderManagerV2.Builder(this)
21 | .map(googleMap)
22 | .enabled(isEnabled)
23 | .radius(initRadiusMetersFinal)
24 | .circleId(circleId)
25 | .strokeWidth(strokeWidth)
26 | .strokeColor(strokeColor)
27 | .fillColor(fillColor)
28 | .minRadius(minRadius)
29 | .maxRadius(maxRadius)
30 | .centerIcon(centerIcon)
31 | .centerBitmap(centerBitmap)
32 | .resizerIcon(resizerIcon)
33 | .centerOffsetHorizontal(centerOffsetHorizontal)
34 | .centerOffsetVertical(centerOffsetVertical)
35 | .build();
36 | ```
37 |
38 | Configuration
39 | ------
40 | There is no pre-configuration needed. :)
41 |
42 | Download
43 | ------
44 | Add the following code to your `build.gradle` file (as described on [JitPack])
45 | ```
46 | repositories {
47 | maven {
48 | url "https://jitpack.io"
49 | }
50 | }
51 | dependencies {
52 | compile 'com.github.ac-opensource:MarkerBuilder:v1.0.8'
53 | }
54 | ```
55 |
56 | License
57 | -------
58 |
59 | Copyright 2015 A-Ar Andrew Concepcion
60 |
61 | Licensed under the Apache License, Version 2.0 (the "License");
62 | you may not use this file except in compliance with the License.
63 | You may obtain a copy of the License at
64 |
65 | http://www.apache.org/licenses/LICENSE-2.0
66 |
67 | Unless required by applicable law or agreed to in writing, software
68 | distributed under the License is distributed on an "AS IS" BASIS,
69 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
70 | See the License for the specific language governing permissions and
71 | limitations under the License.
72 |
73 | [JitPack]:https://jitpack.io/#ac-opensource/MarkerBuilder/v1.0.0
74 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | generateDebugSources
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'me.tatarka.retrolambda'
3 |
4 | android {
5 | compileSdkVersion rootProject.compileSdkVersion
6 | buildToolsVersion rootProject.buildToolsVersion
7 |
8 | def Properties versionProps = new Properties()
9 | def versionPropsFile = file('version.properties')
10 | if(versionPropsFile.exists())
11 | versionProps.load(new FileInputStream(versionPropsFile))
12 | def code = (versionProps['VERSION_CODE'] ?: "0").toInteger() + 1
13 | versionProps['VERSION_CODE'] = code.toString()
14 | versionProps.store(versionPropsFile.newWriter(), null)
15 |
16 | defaultConfig {
17 | applicationId "com.aconcepcion.markerbuilder"
18 | minSdkVersion rootProject.minSdkVersion
19 | targetSdkVersion rootProject.targetSdkVersion
20 | versionCode code
21 | versionName "1.0." + code
22 | }
23 | buildTypes {
24 | release {
25 | minifyEnabled false
26 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
27 | }
28 | }
29 | compileOptions {
30 | sourceCompatibility JavaVersion.VERSION_1_8
31 | targetCompatibility JavaVersion.VERSION_1_8
32 | }
33 | }
34 |
35 | dependencies {
36 | compile fileTree(dir: 'libs', include: ['*.jar'])
37 | compile "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
38 | compile "com.google.android.gms:play-services-maps:$rootProject.playServicesVersion"
39 | compile project(':geofencemarkerbuilder')
40 | }
41 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/andrewconcepcion/Utilities/Utilities/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/aconcepcion/markerbuilder/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.aconcepcion.markerbuilder;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/debug/res/values/google_maps_api.xml:
--------------------------------------------------------------------------------
1 |
2 |
15 |
16 | AIzaSyA0SKYpzdUhe_XMcGyXiKn5RpTLlMFLiL8
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
13 |
14 |
15 |
16 |
21 |
24 |
27 |
28 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aconcepcion/markerbuilder/MapsActivity.java:
--------------------------------------------------------------------------------
1 | package com.aconcepcion.markerbuilder;
2 |
3 | import android.graphics.Color;
4 | import android.os.Bundle;
5 | import android.support.v4.app.FragmentActivity;
6 |
7 | import com.aconcepcion.geofencemarkerbuilder.MarkerBuilderManagerV2;
8 | import com.google.android.gms.maps.GoogleMap;
9 | import com.google.android.gms.maps.GoogleMap.OnMapClickListener;
10 | import com.google.android.gms.maps.SupportMapFragment;
11 | import com.google.android.gms.maps.model.LatLng;
12 | import com.google.android.gms.maps.model.MarkerOptions;
13 |
14 | public class MapsActivity extends FragmentActivity implements OnMapClickListener {
15 |
16 | private GoogleMap mMap; // Might be null if Google Play services APK is not available.
17 | private MarkerBuilderManagerV2 markerBuilderManager;
18 | @Override
19 | protected void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | setContentView(R.layout.activity_maps);
22 | }
23 |
24 | @Override
25 | protected void onResume() {
26 | super.onResume();
27 | setUpMapIfNeeded();
28 | }
29 |
30 | /**
31 | * Sets up the map if it is possible to do so (i.e., the Google Play services APK is correctly
32 | * installed) and the map has not already been instantiated.. This will ensure that we only ever
33 | * call {@link #setUpMap()} once when {@link #mMap} is not null.
34 | *
35 | * If it isn't installed {@link SupportMapFragment} (and
36 | * {@link com.google.android.gms.maps.MapView MapView}) will show a prompt for the user to
37 | * install/update the Google Play services APK on their device.
38 | *
39 | * A user can return to this FragmentActivity after following the prompt and correctly
40 | * installing/updating/enabling the Google Play services. Since the FragmentActivity may not
41 | * have been completely destroyed during this process (it is likely that it would only be
42 | * stopped or paused), {@link #onCreate(Bundle)} may not be called again so we should call this
43 | * method in {@link #onResume()} to guarantee that it will be called.
44 | */
45 | private void setUpMapIfNeeded() {
46 | // Do a null check to confirm that we have not already instantiated the map.
47 | if (mMap == null) {
48 | // Try to obtain the map from the SupportMapFragment.
49 | ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMapAsync(googleMap -> {
50 | mMap = googleMap;
51 | if (mMap != null) {
52 | setUpMap();
53 | }
54 | });
55 | }
56 | }
57 |
58 | /**
59 | * This is where we can add markers or lines, add listeners or move the camera. In this case, we
60 | * just add a marker near Africa.
61 | *
62 | * This should only be called once and when we are sure that {@link #mMap} is not null.
63 | */
64 | private void setUpMap() {
65 | mMap.addMarker(new MarkerOptions().position(new LatLng(0, 0)).title("Marker"));
66 | mMap.setOnMapClickListener(this);
67 |
68 | markerBuilderManager = new MarkerBuilderManagerV2.Builder(this)
69 | .map(mMap)
70 | .enabled(true)
71 | .radius(200)
72 | .fillColor(Color.BLUE)
73 | .build();
74 | }
75 |
76 | @Override
77 | public void onMapClick(LatLng latLng) {
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_maps.xml:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ac-opensource/MarkerBuilder/aa5d5417ca1571e73a88bba85b45a187591022f7/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ac-opensource/MarkerBuilder/aa5d5417ca1571e73a88bba85b45a187591022f7/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ac-opensource/MarkerBuilder/aa5d5417ca1571e73a88bba85b45a187591022f7/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ac-opensource/MarkerBuilder/aa5d5417ca1571e73a88bba85b45a187591022f7/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Marker Builder
3 | Sample Map
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/release/res/values/google_maps_api.xml:
--------------------------------------------------------------------------------
1 |
2 |
15 |
16 | YOUR_KEY_HERE
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/version.properties:
--------------------------------------------------------------------------------
1 | #Sat Feb 25 08:27:44 PHT 2017
2 | VERSION_CODE=8
3 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.2.3'
9 | classpath 'me.tatarka:gradle-retrolambda:3.2.5'
10 |
11 | // NOTE: Do not place your application dependencies here; they belong
12 | // in the individual module build.gradle files
13 | }
14 | }
15 |
16 | allprojects {
17 | repositories {
18 | jcenter()
19 | }
20 | }
21 |
22 |
23 | ext {
24 | // SDK and tools
25 | minSdkVersion = 15
26 | targetSdkVersion = 25
27 | compileSdkVersion = 25
28 | buildToolsVersion = '25.0.1'
29 |
30 | // dependency versions
31 | junitVersion = '4.12'
32 | supportLibraryVersion = '25.0.1'
33 | rxJavaVersion = '1.1.0'
34 | rxAndroidVersion = '1.1.0'
35 | playServicesVersion = '10.0.1'
36 | }
--------------------------------------------------------------------------------
/geofencemarkerbuilder/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/geofencemarkerbuilder/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion rootProject.compileSdkVersion
5 | buildToolsVersion rootProject.buildToolsVersion
6 |
7 | defaultConfig {
8 | minSdkVersion rootProject.minSdkVersion
9 | targetSdkVersion rootProject.targetSdkVersion
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | compileOptions {
20 | sourceCompatibility JavaVersion.VERSION_1_8
21 | targetCompatibility JavaVersion.VERSION_1_8
22 | }
23 | }
24 |
25 | dependencies {
26 | compile fileTree(dir: 'libs', include: ['*.jar'])
27 | compile "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
28 | compile "com.google.android.gms:play-services-maps:$rootProject.playServicesVersion"
29 | }
30 |
--------------------------------------------------------------------------------
/geofencemarkerbuilder/geofencemarkerbuilder.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | generateDebugSources
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
--------------------------------------------------------------------------------
/geofencemarkerbuilder/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/andrewconcepcion/Utilities/Utilities/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/geofencemarkerbuilder/src/androidTest/java/com/aconcepcion/geofencemarkerbuilder/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.aconcepcion.geofencemarkerbuilder;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/geofencemarkerbuilder/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/geofencemarkerbuilder/src/main/java/com/aconcepcion/geofencemarkerbuilder/CircleManagerListener.java:
--------------------------------------------------------------------------------
1 | package com.aconcepcion.geofencemarkerbuilder;
2 |
3 | /**
4 | * Created by andrewconcepcion on 4/28/15.
5 | */
6 | public interface CircleManagerListener {
7 |
8 | /**
9 | * Called when location was initially loaded
10 | * @param draggableCircle created circle
11 | */
12 | void onInitCreateCircle(GeofenceCircle draggableCircle);
13 |
14 | /**
15 | * Called when a circle was placed on the map
16 | * @param draggableCircle created circle
17 | */
18 | void onCircleMarkerClick(GeofenceCircle draggableCircle);
19 |
20 | void onCreateCircle(GeofenceCircle draggableCircle);
21 |
22 | /**
23 | * Called when resizing gesture finishes (user lifts the finger)
24 | * @param draggableCircle resized circle
25 | */
26 | void onResizeCircleEnd(GeofenceCircle draggableCircle);
27 |
28 | /**
29 | * Called when move gesture finishes (user lifts the finger)
30 | * @param draggableCircle move circle
31 | */
32 | void onMoveCircleEnd(GeofenceCircle draggableCircle);
33 |
34 | /**
35 | * Called when move gesture starts (user long presses the position marker)
36 | * @param draggableCircle circle about to be moved
37 | */
38 | void onMoveCircleStart(GeofenceCircle draggableCircle);
39 |
40 | /**
41 | * Called when resize gesture starts (user long presses the resizing marker)
42 | * @param draggableCircle circle about to be resized
43 | */
44 | void onResizeCircleStart(GeofenceCircle draggableCircle);
45 |
46 | /**
47 | * Called when the circle reaches the min possible radius (meters), if it was initialized with a min radius value
48 | * This happens during resizing gesture
49 | * Reducing size is automatically blocked when reached this value - no extra action required for this
50 | *
51 | * @param draggableCircle circle
52 | */
53 | void onMinRadius(GeofenceCircle draggableCircle);
54 |
55 | /**
56 | * Called when the circle reaches the max possible radius (meters), if it was initialized with a max radius value
57 | * This happens during resizing gesture
58 | * Increasing size is automatically blocked when reached this value - no extra action required for this
59 | *
60 | * @param draggableCircle circle
61 | */
62 |
63 | void onMaxRadius(GeofenceCircle draggableCircle);
64 | }
--------------------------------------------------------------------------------
/geofencemarkerbuilder/src/main/java/com/aconcepcion/geofencemarkerbuilder/GeofenceCircle.java:
--------------------------------------------------------------------------------
1 | package com.aconcepcion.geofencemarkerbuilder;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.graphics.Canvas;
6 | import android.graphics.Color;
7 | import android.graphics.Matrix;
8 | import android.graphics.Paint;
9 | import android.graphics.PorterDuff;
10 | import android.graphics.PorterDuffXfermode;
11 | import android.graphics.Rect;
12 | import android.graphics.RectF;
13 | import android.graphics.drawable.BitmapDrawable;
14 | import android.graphics.drawable.Drawable;
15 | import android.support.v4.content.res.ResourcesCompat;
16 |
17 | import com.google.android.gms.maps.GoogleMap;
18 | import com.google.android.gms.maps.model.BitmapDescriptorFactory;
19 | import com.google.android.gms.maps.model.Circle;
20 | import com.google.android.gms.maps.model.CircleOptions;
21 | import com.google.android.gms.maps.model.LatLng;
22 | import com.google.android.gms.maps.model.Marker;
23 | import com.google.android.gms.maps.model.MarkerOptions;
24 |
25 | /**
26 | * Created by andrewconcepcion on 4/20/15.
27 | */
28 | public class GeofenceCircle {
29 | // private final int size;
30 |
31 | public static final String GEOFENCE_WRAPPER = "geofence";
32 | public static final String DATA_POINT_WRAPPER = "dataPoint";
33 |
34 | public long getCircleId() {
35 | return circleId;
36 | }
37 |
38 | public static enum MarkerMoveResult {moved, radiusChange, minRadius, maxRadius, none;};
39 | public static enum MarkerType {move, resize, none;}
40 |
41 |
42 | private static Bitmap centerBitmapCache;
43 |
44 | private Context context;
45 | private GoogleMap map;
46 | private boolean isEnabled;
47 | private LatLng center;
48 | private double radius;
49 | private long circleId;
50 | private float strokeWidth;
51 | private int strokeColor;
52 | private int fillColor;
53 | private int minRadius;
54 | private int maxRadius;
55 | private int centerIcon;
56 | private Bitmap centerBitmap;
57 | private int resizerIcon;
58 | private float centerOffsetHorizontal;
59 | private float centerOffsetVertical;
60 |
61 | private Marker centerMarker;
62 | private Marker resizerMarker;
63 | private Circle circle;
64 |
65 |
66 | public static class Builder {
67 |
68 |
69 | private static int DEFAULT_FILL_COLOR = 0xff0000ff;
70 | private static int DEFAULT_STROKE_COLOR = 0xff000000;
71 | private static int DEFAULT_STROKE_WIDTH = 1;
72 |
73 |
74 | //required
75 | // private final int size;
76 |
77 | //optional
78 | private Context context;
79 | private GoogleMap map;
80 | private boolean isEnabled;
81 | private LatLng center;
82 | private double radius = new MarkerAreaMeasure(200, MarkerAreaMeasure.Unit.meters).value;
83 | private long circleId;
84 | private int fillColor = Color.HSVToColor(70, new float[] {1, 1, 200});
85 | private float strokeWidth = 4f;
86 | private int strokeColor = Color.RED;
87 | private int minRadius = -1;
88 | private int maxRadius = -1;
89 | private int centerIcon = android.R.drawable.ic_menu_mylocation;
90 | private int resizerIcon = android.R.drawable.ic_menu_mylocation;
91 | private Bitmap centerBitmap;
92 | private float centerOffsetHorizontal = 0.5f;
93 | private float centerOffsetVertical = 0.5f;
94 | private float resizerOffsetHorizontal = 0.5f;
95 | private float resizerOffsetVertical = 0.5f;
96 |
97 | private Marker centerMarker;
98 | private Marker resizerMarker;
99 | private Circle circle;
100 |
101 | public Builder(Context context) {
102 | this.context = context;
103 | }
104 |
105 | public Builder map(GoogleMap map) {
106 | this.map = map;
107 | return this;
108 | }
109 |
110 | public Builder enabled(boolean isEnabled) {
111 | this.isEnabled = isEnabled;
112 | return this;
113 | }
114 |
115 | public Builder center(LatLng center) {
116 | this.center = center;
117 | return this;
118 | }
119 |
120 | public Builder radius(double radius) {
121 | this.radius = radius;
122 | return this;
123 | }
124 |
125 | public Builder circleId(long circleId) {
126 | this.circleId = circleId;
127 | return this;
128 | }
129 |
130 | public Builder strokeWidth(float strokeWidth) {
131 | this.strokeWidth = strokeWidth;
132 | return this;
133 | }
134 |
135 | public Builder strokeColor(int strokeColor) {
136 | this.strokeColor = strokeColor;
137 | return this;
138 | }
139 |
140 | public Builder fillColor(int fillColor) {
141 | this.fillColor = fillColor;
142 | return this;
143 | }
144 |
145 | public Builder minRadius(int minRadius) {
146 | this.minRadius = minRadius;
147 | return this;
148 | }
149 |
150 | public Builder maxRadius(int maxRadius) {
151 | this.maxRadius = maxRadius;
152 | return this;
153 | }
154 |
155 | public Builder centerIcon(int centerIcon) {
156 | this.centerIcon = centerIcon;
157 | return this;
158 | }
159 |
160 | public Builder centerBitmap(Bitmap centerBitmap) {
161 | this.centerBitmap = centerBitmap;
162 | return this;
163 | }
164 |
165 | public Builder resizerIcon(int resizerIcon) {
166 | this.resizerIcon = resizerIcon;
167 | return this;
168 | }
169 |
170 | public Builder centerOffsetHorizontal(float centerOffsetHorizontal) {
171 | this.centerOffsetHorizontal = centerOffsetHorizontal;
172 | return this;
173 | }
174 |
175 | public Builder centerOffsetVertical(float centerOffsetVertical) {
176 | this.centerOffsetVertical = centerOffsetVertical;
177 | return this;
178 | }
179 |
180 | public Builder resizerOffsetHorizontal(float resizerOffsetHorizontal) {
181 | this.resizerOffsetHorizontal = resizerOffsetHorizontal;
182 | return this;
183 | }
184 |
185 | public Builder resizerOffsetVertical(float resizerOffsetVertical) {
186 | this.resizerOffsetVertical = resizerOffsetVertical;
187 | return this;
188 | }
189 |
190 | public Bitmap overlay(Bitmap bmp1, Bitmap bmp2) {
191 | Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth(), bmp1.getHeight(), bmp1.getConfig());
192 | Canvas canvas = new Canvas(bmOverlay);
193 | canvas.drawBitmap(bmp1, new Matrix(), null);
194 |
195 | int offset = MetricsUtils.convertDIPsToPixels(context, 5);
196 |
197 | canvas.drawBitmap(bmp2, offset, offset, null);
198 | return bmOverlay;
199 | }
200 |
201 | public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) {
202 | Bitmap output = Bitmap.createBitmap(pixels, pixels, Bitmap.Config.ARGB_8888);
203 | Canvas canvas = new Canvas(output);
204 |
205 | final int color = 0xff424242;
206 | final Paint paint = new Paint();
207 | final Rect rect = new Rect(0, 0, pixels, pixels);
208 | final RectF rectF = new RectF(rect);
209 | final float roundPx = pixels;
210 |
211 | paint.setAntiAlias(true);
212 | canvas.drawARGB(0, 0, 0, 0);
213 | paint.setColor(color);
214 | canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
215 |
216 | paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
217 | canvas.drawBitmap(Bitmap.createScaledBitmap(bitmap, pixels, pixels, false), rect, rect, paint);
218 |
219 | return output;
220 | }
221 |
222 | public GeofenceCircle build(){
223 |
224 | centerMarker = map.addMarker(new MarkerOptions()
225 | .position(center)
226 | .flat(true)
227 | .anchor(centerOffsetHorizontal, centerOffsetVertical)
228 | .draggable(isEnabled));
229 |
230 |
231 | resizerMarker = map.addMarker(new MarkerOptions()
232 | .position(MarkerAreasUtils.toRadiusLatLng(center, radius))
233 | .anchor(resizerOffsetHorizontal, resizerOffsetVertical)
234 | .draggable(isEnabled));
235 |
236 | if (resizerIcon != 0 && resizerIcon != -1) {
237 |
238 | int px = 120;
239 | Bitmap mDotMarkerBitmap = Bitmap.createBitmap(px, px, Bitmap.Config.ARGB_8888);
240 | Canvas canvas = new Canvas(mDotMarkerBitmap);
241 | Drawable shape = ResourcesCompat.getDrawable(context.getResources(), resizerIcon, null);
242 | shape.setBounds(0, 0, mDotMarkerBitmap.getWidth(), mDotMarkerBitmap.getHeight());
243 | shape.draw(canvas);
244 |
245 | resizerMarker.setIcon(BitmapDescriptorFactory.fromBitmap(mDotMarkerBitmap));
246 | }
247 |
248 |
249 |
250 | if (centerIcon != -1) {
251 | BitmapDrawable bitmapDrawable = (BitmapDrawable) context.getResources().getDrawable(centerIcon);
252 | Bitmap bitmap = bitmapDrawable.getBitmap();
253 | Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, (int)(bitmap.getWidth() / 2), (int)(bitmap.getHeight() / 2), false);
254 | // centerMarker.setIcon(BitmapDescriptorFactory.fromBitmap(scaledBitmap));
255 |
256 | int imageSize = (MetricsUtils.convertDIPsToPixels(context, 30f));
257 |
258 | if (centerBitmap == null) {
259 | if(centerBitmapCache == null) {
260 | centerBitmap = Bitmap.createBitmap(imageSize, imageSize, Bitmap.Config.RGB_565);
261 | Drawable drawable = context.getResources().getDrawable(android.R.drawable.sym_def_app_icon);
262 | Canvas canvas = new Canvas(centerBitmap);
263 | drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
264 | drawable.draw(canvas);
265 | centerBitmapCache = centerBitmap;
266 | } else {
267 | centerBitmap = centerBitmapCache;
268 | }
269 |
270 | }
271 |
272 | // centerMarker.setIcon(BitmapDescriptorFactory.fromBitmap(overlay(scaledBitmap, getRoundedCornerBitmap(centerBitmap, imageSize))));
273 | }
274 |
275 | circle = map.addCircle(new CircleOptions()
276 | .center(center)
277 | .radius(radius)
278 | .strokeWidth(strokeWidth)
279 | .strokeColor(strokeColor)
280 | .fillColor(fillColor));
281 |
282 | return new GeofenceCircle(this);
283 | }
284 | }
285 |
286 | private GeofenceCircle(Builder b) {
287 | this.context = b.context;
288 | this.map = b.map;
289 | this.isEnabled = b.isEnabled;
290 | this.center = b.center;
291 | this.radius = b.radius;
292 | this.circleId = b.circleId;
293 | this.strokeWidth = b.strokeWidth;
294 | this.strokeColor = b.strokeColor;
295 | this.fillColor = b.fillColor;
296 | this.minRadius = b.minRadius;
297 | this.maxRadius = b.maxRadius;
298 | this.centerIcon = b.centerIcon;
299 | this.centerBitmap = b.centerBitmap;
300 | this.resizerIcon = b.resizerIcon;
301 | this.centerOffsetHorizontal = b.centerOffsetHorizontal;
302 | this.centerOffsetVertical = b.centerOffsetVertical;
303 | this.centerMarker = b.centerMarker;
304 | this.resizerMarker = b.resizerMarker;
305 | this.circle = b.circle;
306 |
307 | }
308 |
309 | public void setCenter(LatLng center) {
310 | centerMarker.setPosition(center);
311 | onCenterUpdated(center);
312 | }
313 |
314 | public void removeArea() {
315 | if(resizerMarker != null) resizerMarker.remove();
316 | if(centerMarker != null) centerMarker.remove();
317 | if(circle != null) circle.remove();
318 | }
319 |
320 |
321 | /**
322 | * This modifies circle according to marker's type and position
323 | *
324 | * if the marker is position marker (from this circle), the circle will be moved according to marker's position
325 | * if the marker is resizing marker (from this circle), the circle will be resized according to marker's position
326 | *
327 | * If the marker is not in this circle (it's not the position or resizing marker) no action will be done
328 | *
329 | * @param marker
330 | *
331 | * @return flag indicating which action was done.
332 | * When the marker is not in this circle returned action is MarkerMoveResult.none
333 | */
334 | public MarkerMoveResult onMarkerMoved(Marker marker) {
335 | if (marker.equals(centerMarker)) {
336 | onCenterUpdated(marker.getPosition());
337 | return MarkerMoveResult.moved;
338 | }
339 |
340 | if (marker.equals(resizerMarker)) {
341 | double newRadius = MarkerAreasUtils.toRadiusMeters(centerMarker.getPosition(), marker.getPosition());
342 |
343 | if (minRadius != -1 && newRadius < minRadius) {
344 | return MarkerMoveResult.minRadius;
345 |
346 | } else if (maxRadius != -1 && newRadius > maxRadius) {
347 | return MarkerMoveResult.maxRadius;
348 |
349 | } else {
350 | setRadius(newRadius);
351 |
352 | return MarkerMoveResult.radiusChange;
353 | }
354 |
355 | }
356 | return MarkerMoveResult.none;
357 | }
358 |
359 |
360 |
361 | /**
362 | * Called after update position of center marker, to update the circle and the radius marker
363 | * @param center
364 | */
365 | public void onCenterUpdated(LatLng center) {
366 | if(circle != null) circle.setCenter(center);
367 | if(resizerMarker != null) resizerMarker.setPosition(MarkerAreasUtils.toRadiusLatLng(center, radius));
368 | }
369 |
370 | /**
371 | * Set the radius of circle
372 | * the map circle will be updated immediately
373 | *
374 | * @param radius
375 | */
376 | public void setRadius(double radius) {
377 | this.radius = radius;
378 | circle.setRadius(radius);
379 | }
380 |
381 | public LatLng getCenter() {
382 | return center;
383 | }
384 |
385 | public double getRadius() {
386 | return radius;
387 | }
388 |
389 |
390 |
391 | @Override
392 | public String toString() {
393 | return "center: " + getCenter() + " radius: " + getRadius();
394 | }
395 |
396 |
397 | }
--------------------------------------------------------------------------------
/geofencemarkerbuilder/src/main/java/com/aconcepcion/geofencemarkerbuilder/MapDataPointWrapper.java:
--------------------------------------------------------------------------------
1 | package com.aconcepcion.geofencemarkerbuilder;
2 |
3 | /**
4 | * This class manages a map circle, with markers
5 | *
6 | * Currently there's position marker (in the middle) and resizing marker (in border)
7 | * Long pressing these markers allow to change circle position or size.
8 | *
9 | * @author A-Ar Andrew Concepcion
10 | *
11 | */
12 |
13 | import android.content.Context;
14 | import android.graphics.Bitmap;
15 | import android.graphics.Canvas;
16 | import android.graphics.drawable.BitmapDrawable;
17 | import android.graphics.drawable.Drawable;
18 |
19 | import com.google.android.gms.maps.GoogleMap;
20 | import com.google.android.gms.maps.model.BitmapDescriptorFactory;
21 | import com.google.android.gms.maps.model.Circle;
22 | import com.google.android.gms.maps.model.CircleOptions;
23 | import com.google.android.gms.maps.model.LatLng;
24 | import com.google.android.gms.maps.model.Marker;
25 | import com.google.android.gms.maps.model.MarkerOptions;
26 |
27 | /**
28 | * Created by andrewconcepcion on 12/3/14.
29 | */
30 |
31 | public class MapDataPointWrapper {
32 |
33 | public static enum MarkerMoveResult {moved, radiusChange, minRadius, maxRadius, none};
34 | public static enum MarkerType {move, resize, none}
35 |
36 | private Marker centerMarker;
37 | private Marker radiusMarker;
38 | private Circle circle;
39 | private double radiusMeters;
40 | private long geofenceCircleId;
41 | private int count;
42 | private boolean isEnabled;
43 |
44 | private int minRadiusMeters = -1;
45 | private int maxRadiusMeters = -1;
46 |
47 | /**
48 | * Primary constructor
49 | *
50 | * @param map
51 | * @param center center of circle in geo coordinates
52 | * @param radiusMeters radius of circle in meters
53 | * @param strokeWidth circle stroke with in pixels
54 | * @param strokeColor circle stroke color
55 | * @param fillColor circle fill color
56 | * @param minRadiusMeters optional - circle min radius in meters (circle will not shrink bellow this, and callback is called when reached)
57 | * @param maxRadiusMeters optional - circle max radius in meters (circle will not expand above this, and callback is called when reached)
58 | * @param centerDrawableId drawable ressource id for positioning marker. If not set a default geomarker is used
59 | * @param radiusDrawableId drawable ressource id for resizing marker. If not set a default geomarker is used
60 | * @param moveDrawableAnchorU horizontal anchor for move drawable
61 | * @param moveDrawableAnchorV vertical anchor for move drawable
62 | * @param resizeDrawableAnchorU horizontal anchor for resize drawable
63 | * @param resizeDrawableAnchorV vertical anchor for resize drawable
64 | */
65 | public MapDataPointWrapper(Context context, GoogleMap map, boolean isEnabled, LatLng center, int count, int centerDrawableId) {
66 | this.isEnabled = isEnabled;
67 | this.count = count;
68 |
69 | centerMarker = map.addMarker(new MarkerOptions()
70 | .position(center)
71 | .flat(true)
72 | .draggable(isEnabled));
73 |
74 | if (centerDrawableId != -1) {
75 | BitmapDrawable bitmapDrawable = (BitmapDrawable) context.getResources().getDrawable(centerDrawableId);
76 | Bitmap bitmap = bitmapDrawable.getBitmap();
77 | Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, bitmap.getWidth()/2, bitmap.getHeight()/2, false);
78 | centerMarker.setIcon(BitmapDescriptorFactory.fromBitmap(scaledBitmap));
79 | }
80 | }
81 |
82 | public static Bitmap drawableToBitmap (Drawable drawable) {
83 | Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
84 | Canvas canvas = new Canvas(bitmap);
85 | drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
86 | drawable.draw(canvas);
87 | return bitmap;
88 | }
89 |
90 | /**
91 | * @return center of circle in geocoordinates
92 | */
93 | public LatLng getCenter() {
94 | return centerMarker.getPosition();
95 | }
96 |
97 | public long getGeofenceCircleId() { return geofenceCircleId; }
98 |
99 | public void removeArea() {
100 | centerMarker.remove();
101 | }
102 |
103 | @Override
104 | public String toString() {
105 | return "center: " + getCenter();
106 | }
107 | }
--------------------------------------------------------------------------------
/geofencemarkerbuilder/src/main/java/com/aconcepcion/geofencemarkerbuilder/MarkerAreaMeasure.java:
--------------------------------------------------------------------------------
1 | package com.aconcepcion.geofencemarkerbuilder;
2 |
3 | /**
4 | * MapAreaMeasure
5 | *
6 | * @author A-Ar Andrew Concepcion
7 | */
8 | public class MarkerAreaMeasure {
9 |
10 | public static enum Unit {pixels, meters}
11 |
12 | public double value;
13 | public Unit unit;
14 |
15 | public MarkerAreaMeasure(double value, Unit unit) {
16 | this.value = value;
17 | this.unit = unit;
18 | }
19 | }
--------------------------------------------------------------------------------
/geofencemarkerbuilder/src/main/java/com/aconcepcion/geofencemarkerbuilder/MarkerAreaWrapper.java:
--------------------------------------------------------------------------------
1 | package com.aconcepcion.geofencemarkerbuilder;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.graphics.Canvas;
6 | import android.graphics.Matrix;
7 | import android.graphics.Paint;
8 | import android.graphics.PorterDuff;
9 | import android.graphics.PorterDuffXfermode;
10 | import android.graphics.Rect;
11 | import android.graphics.RectF;
12 | import android.graphics.drawable.BitmapDrawable;
13 | import android.graphics.drawable.Drawable;
14 | import android.support.v4.content.res.ResourcesCompat;
15 |
16 | import com.google.android.gms.maps.GoogleMap;
17 | import com.google.android.gms.maps.model.BitmapDescriptorFactory;
18 | import com.google.android.gms.maps.model.Circle;
19 | import com.google.android.gms.maps.model.CircleOptions;
20 | import com.google.android.gms.maps.model.LatLng;
21 | import com.google.android.gms.maps.model.Marker;
22 | import com.google.android.gms.maps.model.MarkerOptions;
23 |
24 | import java.util.ArrayList;
25 |
26 |
27 | /**
28 | * This class manages a map circle, with markers
29 | *
30 | * Currently there's position marker (in the middle) and resizing marker (in border)
31 | * Long pressing these markers allow to change circle position or size.
32 | *
33 | * @author A-Ar Andrew Concepcion
34 | *
35 | */
36 |
37 | public class MarkerAreaWrapper {
38 |
39 | public static final String GEOFENCE_WRAPPER = "geofence";
40 | public static final String DATA_POINT_WRAPPER = "dataPoint";
41 |
42 | private Marker centerMarker;
43 | private Marker radiusMarker;
44 | private Circle circle;
45 |
46 | private static Bitmap childBitmap;
47 |
48 | private double radiusMeters;
49 | private long geofenceCircleId;
50 | private boolean isEnabled;
51 | private int fillColor;
52 |
53 | private String mapAreaType;
54 | private int count;
55 | private boolean shouldExpand;
56 | private ArrayList