-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a021c16
commit 9f20ba7
Showing
16 changed files
with
456 additions
and
127 deletions.
There are no files selected for viewing
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
app/src/main/java/com/example/prabhat/locationsample/CustomInfoWindowForGoogleMap.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.example.prabhat.locationsample | ||
|
||
import android.app.Activity | ||
import android.content.Context | ||
import android.view.View | ||
import android.widget.TextView | ||
import com.google.android.gms.maps.GoogleMap | ||
import com.google.android.gms.maps.model.Marker | ||
import org.json.JSONObject | ||
import java.lang.Exception | ||
import java.text.DecimalFormat | ||
|
||
class CustomInfoWindowForGoogleMap(context: Context): GoogleMap.InfoWindowAdapter { | ||
private val df: DecimalFormat = DecimalFormat("0.00") | ||
|
||
var mWindow = (context as Activity).layoutInflater.inflate(R.layout.marker_window, null) | ||
|
||
|
||
override fun getInfoWindow(p0: Marker?): View { | ||
render(p0, mWindow) | ||
return mWindow | ||
} | ||
|
||
override fun getInfoContents(p0: Marker?): View { | ||
render(p0, mWindow) | ||
return mWindow | ||
} | ||
|
||
private fun render(marker: Marker?, mWindow: View) { | ||
|
||
val title = mWindow.findViewById<TextView>(R.id.textView) | ||
val time = mWindow.findViewById<TextView>(R.id.textView2) | ||
val distance = mWindow.findViewById<TextView>(R.id.textView3) | ||
try { | ||
val json = JSONObject(marker?.title) | ||
title.text = json.getString("placeSummary") | ||
if (json.getString("time").isNotEmpty()){ | ||
time.visibility = View.VISIBLE | ||
distance.visibility = View.VISIBLE | ||
time.text = df.format(json.getString("timeFromPrevPoint").toDouble()/60) + " sec" | ||
distance.text = df.format(json.getString("distanceFromPrevPoint").toDouble()/1609.344)+" mile" | ||
}else{ | ||
time.visibility = View.GONE | ||
distance.visibility = View.GONE | ||
} | ||
}catch (e:Exception){ | ||
e.printStackTrace() | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,38 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<fragment xmlns:android="http://schemas.android.com/apk/res/android" | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:id="@+id/map" | ||
android:name="com.google.android.gms.maps.SupportMapFragment" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".MapsActivity" /> | ||
xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<fragment | ||
android:id="@+id/map" | ||
android:name="com.google.android.gms.maps.SupportMapFragment" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintHorizontal_bias="1.0" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:layout_constraintVertical_bias="0.0" | ||
tools:context=".MapsActivity" /> | ||
|
||
<Button | ||
android:id="@+id/button2" | ||
android:layout_width="wrap_content" | ||
android:layout_height="48dp" | ||
android:text="Start Ride" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="@+id/guideline" /> | ||
|
||
<androidx.constraintlayout.widget.Guideline | ||
android:id="@+id/guideline" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:orientation="horizontal" | ||
app:layout_constraintGuide_percent=".8" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:background="#fff" | ||
android:padding="8dp" | ||
android:layout_height="wrap_content"> | ||
|
||
<TextView | ||
android:id="@+id/textView" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="8dp" | ||
android:text="TextView" | ||
android:textStyle="bold" | ||
android:textColor="@color/black" | ||
app:layout_constraintBottom_toTopOf="@+id/textView2" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<TextView | ||
android:id="@+id/textView2" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="8dp" | ||
android:textColor="@color/black" | ||
android:text="TextView" | ||
app:layout_constraintBottom_toTopOf="@+id/textView3" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/textView" /> | ||
|
||
<TextView | ||
android:id="@+id/textView3" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="8dp" | ||
android:layout_marginBottom="5dp" | ||
android:textColor="@color/black" | ||
android:text="TextView" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/textView2" /> | ||
</androidx.constraintlayout.widget.ConstraintLayout> |
Oops, something went wrong.