Skip to content

Commit ac796ad

Browse files
authored
Merge pull request #21 from prabhat1707/feature/arc_polyline
Feature/arc polyline
2 parents 2a359ad + c5fb88b commit ac796ad

File tree

17 files changed

+666
-124
lines changed

17 files changed

+666
-124
lines changed
-3 Bytes
Binary file not shown.

.idea/codeStyles/Project.xml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/compiler.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,7 @@ dependencies {
3232
implementation project(':easywaylocation')
3333
implementation 'com.google.android.gms:play-services-maps:17.0.0'
3434
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
35+
implementation 'com.google.maps.android:android-maps-utils:0.6.2'
36+
implementation 'androidx.cardview:cardview:1.0.0'
37+
3538
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package com.example.prabhat.locationsample
2+
3+
import android.app.Activity
4+
import android.content.Context
5+
import android.view.View
6+
import android.widget.TextView
7+
import com.google.android.gms.maps.GoogleMap
8+
import com.google.android.gms.maps.model.Marker
9+
import org.json.JSONObject
10+
import java.lang.Exception
11+
import java.text.DecimalFormat
12+
13+
class CustomInfoWindowForGoogleMap(context: Context): GoogleMap.InfoWindowAdapter {
14+
private val df: DecimalFormat = DecimalFormat("0.00")
15+
16+
var mWindow = (context as Activity).layoutInflater.inflate(R.layout.marker_window, null)
17+
18+
19+
override fun getInfoWindow(p0: Marker?): View {
20+
render(p0, mWindow)
21+
return mWindow
22+
}
23+
24+
override fun getInfoContents(p0: Marker?): View {
25+
render(p0, mWindow)
26+
return mWindow
27+
}
28+
29+
private fun render(marker: Marker?, mWindow: View) {
30+
31+
val title = mWindow.findViewById<TextView>(R.id.textView)
32+
val time = mWindow.findViewById<TextView>(R.id.textView2)
33+
val distance = mWindow.findViewById<TextView>(R.id.textView3)
34+
try {
35+
val json = JSONObject(marker?.title)
36+
title.text = json.getString("placeSummary")
37+
if (json.getString("time").isNotEmpty()){
38+
time.visibility = View.VISIBLE
39+
distance.visibility = View.VISIBLE
40+
time.text = df.format(json.getString("timeFromPrevPoint").toDouble()/60) + " sec"
41+
distance.text = df.format(json.getString("distanceFromPrevPoint").toDouble()/1609.344)+" mile"
42+
}else{
43+
time.visibility = View.GONE
44+
distance.visibility = View.GONE
45+
}
46+
}catch (e:Exception){
47+
e.printStackTrace()
48+
}
49+
50+
}
51+
}

0 commit comments

Comments
 (0)