Last active
September 23, 2020 13:15
-
-
Save yusufceylan/949fab891a8d43ae9b238179cb02dc62 to your computer and use it in GitHub Desktop.
Add Simple Marker
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
/** | |
* Initialize dummy markers | |
*/ | |
private fun initMarkers() { | |
val markerDataList = createMarkerList() | |
markerDataList.forEachIndexed { index, markerOptions -> | |
val marker = hMap?.addMarker(markerOptions) | |
marker?.setMarkerAnchor(0.5f, 1f) // Set marker anchor point | |
marker?.tag = "$index Extra Info" // Set extra data with tag. This data can be a custom class | |
} | |
hMap?.setMarkersClustering(true) // Enable clustering | |
hMap?.moveCamera(CameraUpdateFactory.newLatLngZoom(markerDataList[0].position, 10f)) // Move camera to first item | |
} | |
fun createMarkerList() : List<MarkerOptions> { | |
val markerOptions = arrayListOf<MarkerOptions>() | |
val latLangList = dummyLatLangList() | |
latLangList.forEachIndexed { index, latLng -> | |
val options = MarkerOptions() | |
.position(latLng) | |
.title("$index Market Title") | |
.snippet("$index snippet!") | |
.clusterable(true) // Make it clusterable | |
markerOptions.add(options) | |
} | |
return markerOptions | |
} | |
private fun dummyLatLangList() : ArrayList<LatLng> { | |
val list = arrayListOf<LatLng>() | |
list.add(LatLng(41.032284, 29.032708)) | |
list.add(LatLng(41.031442, 29.032322)) | |
list.add(LatLng(41.031507, 29.030369)) | |
list.add(LatLng(41.032527, 29.030358)) | |
list.add(LatLng(41.034081, 29.030787)) | |
list.add(LatLng(41.026767, 29.033660)) | |
list.add(LatLng(41.027885, 29.029466)) | |
list.add(LatLng(41.029577, 29.030861)) | |
list.add(LatLng(41.030451, 29.028737)) | |
list.add(LatLng(41.029666, 29.027503)) | |
list.add(LatLng(41.028865, 29.027321)) | |
list.add(LatLng(41.027934, 29.027375)) | |
return list | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment