尝试在android项目上的tomtom地图中添加自定义图标标记
这里的函数用于此:
private fun addingStation() {
val i = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_dialog_alert, null)
val database = FirebaseDatabase.getInstance()
val myRef = database.getReference("station")
// Read from the database
myRef.addValueEventListener(object : ValueEventListener {
override fun onDataChange(dataSnapshot: DataSnapshot) {
for (ds in dataSnapshot.getChildren()) {
val name = ds.child("station_name").getValue(String::class.java)
val stationLongitude = ds.child("station_longitude").getValue(String::class.java)
val stationLatitude = ds.child("station_latitude").getValue(String::class.java)
val longitude = stationLongitude.let { java.lang.Double.parseDouble(it!!) }
val latitude = stationLatitude.let { java.lang.Double.parseDouble(it!!) }
val currentLatLng = LatLng(latitude, longitude)
val balloon = SimpleMarkerBalloon(name)
map.addMarker(MarkerBuilder(currentLatLng).
markerBalloon(balloon)
.icon(i))
}
}
override fun onCancelled(error: DatabaseError) {
// Failed to read value
println("failed")
}
})
val currentLatLng = LatLng(31.233334, 30.033333)
val balloon = SimpleMarkerBalloon("cairo are Here")
map.addMarker(MarkerBuilder(currentLatLng).markerBalloon(balloon))
}
代码给了我这个错误:
要求:图标!, 发现:可绘制?
在调试导致错误的行之后
map.addMarker(MarkerBuilder(currentLatLng).
markerBalloon(balloon)
.icon(i))