В Android API есть очень удобный для этого класс, IconGenerator
. Используя IconGenerator
в своем приложении для Android, я могу легко сделать маркер, который:
- - это простой прямоугольник с цветом моего выбора.
- изменяет размер, чтобы сохранить текст любой длины.
- НЕ информационное окно. Я хочу, чтобы сам маркер содержал текст, как показано на изображении ниже, из версии Android.
// Android - problem solved with IconGenerator
IconGenerator iconGenerator = new IconGenerator(context);
iconGenerator.setStyle(IconGenerator.STYLE_GREEN); // or any other color
Bitmap iconBitmap = iconGenerator.makeIcon(myString);
Marker m = new MarkerOptions().icon(BitmapDescriptorFactory.fromBitmap(iconBitmap))
.position(myLatLng);
map.addMarker(m); // map is a com.google.android.gms.maps.GoogleMap
Есть ли способ сделать что-то столь же простое, как это в iOS, используя Swift? Недавно был анонсирован iOS api, который позволяет "настроить маркер" , но я не вижу, как применить его к этому варианту использования.
// iOS (Swift) - I don't know how to create the icon as in code above
let marker = GMSMarker(position: myLatLng)
marker.icon = // How can I set to a rectangle with color/text of my choosing?
marker.map = map // map is a GMSMapView