Added info window
@ -3,9 +3,13 @@ package fishrungames.yelpmapapp
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import android.widget.LinearLayout
|
||||
import com.google.android.gms.maps.model.Marker
|
||||
import android.widget.TextView
|
||||
import com.google.android.gms.maps.GoogleMap.InfoWindowAdapter
|
||||
import android.widget.RelativeLayout
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -13,12 +17,17 @@ import com.google.android.gms.maps.GoogleMap.InfoWindowAdapter
|
||||
* Created by mephi on 10.06.2017.
|
||||
*/
|
||||
|
||||
internal class MyInfoWindowAdapter(val activity: Activity) : InfoWindowAdapter {
|
||||
class YelpInfoWindowProvider(val activity: Activity) : InfoWindowAdapter {
|
||||
|
||||
private val myContentsView: View = activity.layoutInflater.inflate(R.layout.yelp_info_contents, null)
|
||||
|
||||
override fun getInfoContents(marker: Marker): View {
|
||||
|
||||
|
||||
//val contentsView = activity.layoutInflater.inflate(R.layout.yelp_info_contents, null)
|
||||
|
||||
//myContentsView.layoutParams = LinearLayout.LayoutParams(500, RelativeLayout.LayoutParams.WRAP_CONTENT)
|
||||
|
||||
//myContentsView.findViewById(R.id.title) = marker.title
|
||||
//myContentsView.findViewById(R.id.snippet).text = marker.snippet
|
||||
|
||||
|
@ -10,6 +10,9 @@ import com.google.android.gms.maps.model.LatLng
|
||||
import java.util.*
|
||||
import com.google.maps.android.clustering.ClusterManager
|
||||
import com.google.android.gms.maps.CameraUpdateFactory
|
||||
import android.widget.Toast
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -21,13 +24,15 @@ import com.google.android.gms.maps.CameraUpdateFactory
|
||||
*/
|
||||
|
||||
|
||||
class YelpMapActivity : MapsActivity()
|
||||
class YelpMapActivity : MapsActivity(), GoogleMap.OnInfoWindowClickListener
|
||||
{
|
||||
|
||||
val handler = Handler()
|
||||
|
||||
val dataProvider = DataProvider(this, this::handleMarkersUpdated)
|
||||
|
||||
var yelpInfoWindowProvider : YelpInfoWindowProvider? = null
|
||||
|
||||
private var mClusterManager: ClusterManager<MapMarkerClusterItem>? = null
|
||||
|
||||
val markerMap = mutableMapOf<String, MapMarkerClusterItem>()
|
||||
@ -45,6 +50,12 @@ class YelpMapActivity : MapsActivity()
|
||||
|
||||
}
|
||||
|
||||
googleMap.setOnInfoWindowClickListener(this)
|
||||
|
||||
yelpInfoWindowProvider = YelpInfoWindowProvider(this)
|
||||
|
||||
googleMap.setInfoWindowAdapter(yelpInfoWindowProvider)
|
||||
|
||||
setUpClusterer(googleMap)
|
||||
}
|
||||
|
||||
@ -137,5 +148,10 @@ class YelpMapActivity : MapsActivity()
|
||||
|
||||
}
|
||||
|
||||
override fun onInfoWindowClick(marker: Marker) {
|
||||
Toast.makeText(this, "Info window clicked",
|
||||
Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
|
||||
}
|
BIN
app/src/main/res/drawable-hdpi/ic_star_black_48dp.png
Executable file
After Width: | Height: | Size: 668 B |
BIN
app/src/main/res/drawable-hdpi/ic_star_border_black_48dp.png
Executable file
After Width: | Height: | Size: 971 B |
BIN
app/src/main/res/drawable-hdpi/ic_star_half_black_48dp.png
Executable file
After Width: | Height: | Size: 836 B |
BIN
app/src/main/res/drawable-mdpi/ic_star_black_48dp.png
Executable file
After Width: | Height: | Size: 467 B |
BIN
app/src/main/res/drawable-mdpi/ic_star_border_black_48dp.png
Executable file
After Width: | Height: | Size: 674 B |
BIN
app/src/main/res/drawable-mdpi/ic_star_half_black_48dp.png
Executable file
After Width: | Height: | Size: 574 B |
BIN
app/src/main/res/drawable-xhdpi/ic_star_black_48dp.png
Executable file
After Width: | Height: | Size: 887 B |
BIN
app/src/main/res/drawable-xhdpi/ic_star_border_black_48dp.png
Executable file
After Width: | Height: | Size: 1.3 KiB |
BIN
app/src/main/res/drawable-xhdpi/ic_star_half_black_48dp.png
Executable file
After Width: | Height: | Size: 1.1 KiB |
BIN
app/src/main/res/drawable-xxhdpi/ic_star_black_48dp.png
Executable file
After Width: | Height: | Size: 1.3 KiB |
BIN
app/src/main/res/drawable-xxhdpi/ic_star_border_black_48dp.png
Executable file
After Width: | Height: | Size: 1.9 KiB |
BIN
app/src/main/res/drawable-xxhdpi/ic_star_half_black_48dp.png
Executable file
After Width: | Height: | Size: 1.6 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/ic_star_black_48dp.png
Executable file
After Width: | Height: | Size: 1.6 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/ic_star_border_black_48dp.png
Executable file
After Width: | Height: | Size: 2.5 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/ic_star_half_black_48dp.png
Executable file
After Width: | Height: | Size: 2.1 KiB |
@ -1,6 +1,90 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="250dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="6dp"
|
||||
android:text="McDonalds"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Large" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginBottom="6dp"
|
||||
android:background="@android:color/black" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Rating:"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/starImageView1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_star_border_black_48dp"
|
||||
app:srcCompat="@drawable/ic_star_border_black_48dp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/starImageView2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_star_border_black_48dp"
|
||||
app:srcCompat="@drawable/ic_star_border_black_48dp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/starImageView3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_star_border_black_48dp"
|
||||
app:srcCompat="@drawable/ic_star_border_black_48dp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/starImageView4"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_star_border_black_48dp"
|
||||
app:srcCompat="@drawable/ic_star_border_black_48dp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/starImageView5"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_star_border_black_48dp"
|
||||
app:srcCompat="@drawable/ic_star_border_black_48dp" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView3"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Address:"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView4"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="123 Main" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|