Skip to content

Commit

Permalink
mvp working gmap patterner implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
AmosKorir committed Apr 22, 2021
1 parent 3325f01 commit e290c55
Show file tree
Hide file tree
Showing 14 changed files with 344 additions and 23 deletions.
139 changes: 139 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@ plugins {
id 'kotlin-android'
}

def localProperties = new Properties()
localProperties.load(new FileInputStream(rootProject.file("local.properties")))


android {
compileSdkVersion 30
buildToolsVersion "30.0.0"
buildToolsVersion "30.0.3"

defaultConfig {
manifestPlaceholders = [mapKey:localProperties["api_map_key"]]
applicationId "com.amoskorir.patterner"
minSdkVersion 30
minSdkVersion 24
targetSdkVersion 30
versionCode 1
versionName "1.0"
Expand Down Expand Up @@ -40,7 +45,9 @@ dependencies {
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
implementation project(path: ':patterner')
testImplementation 'junit:junit:4.+'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

}
5 changes: 4 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.amoskorir.patterner">

<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
Expand All @@ -16,6 +16,9 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="${mapKey}" />
</application>

</manifest>
63 changes: 57 additions & 6 deletions app/src/main/java/com/amoskorir/patterner/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,62 @@
package com.amoskorir.patterner

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.google.android.gms.maps.*
import com.google.android.gms.maps.model.LatLng
import com.google.android.gms.maps.model.MarkerOptions
import com.google.android.gms.maps.model.PolygonOptions


class MainActivity : AppCompatActivity(), OnMapReadyCallback {

var googleMap: GoogleMap? = null
lateinit var mapView: MapView

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
initializeMap(savedInstanceState)
}

override fun onMapReady(map: GoogleMap?) {
googleMap = map
googleMap?.let {
val zoomLevel = 7.0f //This goes up to 21
it.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(-0.3031, 36.0800), zoomLevel))
drawPolygon(it)
}
}

private fun drawPolygon(map: GoogleMap) {
val one = LatLng(0.5143, 35.2698)
val two = LatLng(-0.3031, 36.0800)
val four = LatLng(-1.2921, 36.8219)
val three = LatLng(-0.0917, 34.7680)


val list = listOf(one, two, four,three)

val polygonOptions = PolygonOptions()
polygonOptions.addAll(list)
val groundOverlay = GMapPattern.getBitmapPolygonGround(
this,
polygonOptions,
500,
500,
R.drawable.example_pattern
)

map.addGroundOverlay(groundOverlay)

map.addPolygon(polygonOptions)
}

class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
private fun initializeMap(savedInstanceState: Bundle?) {
mapView = findViewById(R.id.mapView)
mapView.onCreate(savedInstanceState)
MapsInitializer.initialize(this)
mapView.onResume()
mapView.getMapAsync(this)
}
}
Binary file added app/src/main/res/drawable/example_pattern.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 8 additions & 9 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
android:layout_height="match_parent"
tools:context=".MainActivity"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>

<com.google.android.gms.maps.MapView
android:id="@+id/mapView"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
4 changes: 2 additions & 2 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color>
<color name="purple_500">#F44336</color>
<color name="purple_700">#FF5722</color>
<color name="teal_200">#FF03DAC5</color>
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ buildscript {
dependencies {
classpath "com.android.tools.build:gradle:4.1.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Oct 25 08:53:24 EAT 2020
#Thu Apr 22 18:08:13 EAT 2021
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
7 changes: 7 additions & 0 deletions patterner/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
plugins {
id 'com.android.library'
id 'kotlin-android'

}

apply plugin: 'com.github.dcendents.android-maven'
group='com.github.amoskorir'

android {
compileSdkVersion 30
buildToolsVersion "30.0.0"
Expand Down Expand Up @@ -38,7 +42,10 @@ dependencies {
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.google.maps.android:android-maps-utils:1.3.3'

}
Loading

0 comments on commit e290c55

Please sign in to comment.