Skip to content
This repository was archived by the owner on Jun 25, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.2-4'
classpath "org.jetbrains.kotlin:kotlin-android-extensions:1.1.2-4'"
}
}

Expand All @@ -26,6 +27,7 @@ rootProject.allprojects {

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 27
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.apptreesoftware.mapview
import android.app.Activity
import android.content.Context
import android.view.View
import android.view.LayoutInflater
import android.widget.ImageView
import android.widget.TextView
import android.text.Html
import android.text.Spanned
import android.os.Build

import com.google.android.gms.maps.GoogleMap
import com.google.android.gms.maps.model.Marker
import kotlinx.android.synthetic.main.map_custom_infowindow.view.*


class CustomInfoWindowGoogleMap(private val context: Context) : GoogleMap.InfoWindowAdapter {


override fun getInfoWindow(marker: Marker): View? {
return null
}


override fun getInfoContents(marker: Marker): View {

val view = LayoutInflater.from(context).inflate(R.layout.map_custom_infowindow, null)

view.name.text = fromHtml(marker.getTitle())

return view
}

@SuppressWarnings("deprecation")
fun fromHtml(html: String): Spanned {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Html.fromHtml(html, Html.FROM_HTML_MODE_LEGACY)
} else {
Html.fromHtml(html)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class MapActivity : AppCompatActivity(),
@SuppressLint("MissingPermission")
override fun onMapReady(map: GoogleMap) {
googleMap = map

map.setInfoWindowAdapter(CustomInfoWindowGoogleMap(this))
map.setMapType(MapViewPlugin.mapViewType)

if (MapViewPlugin.showUserLocation) {
Expand Down
14 changes: 14 additions & 0 deletions android/src/main/res/layout/map_custom_infowindow.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>

</LinearLayout>