break;
}
+ return error;
+}
+
+mapzen_error_e TangramView::getBitmapMarkerImage(maps_view_object_h object, unsigned char *&imgData, int &imgWidth, int &imgHeight) {
+ char *imgPath = nullptr;
+ Evas_Object *img = nullptr;
+ int imgSize = 0;
+ int error = MAPS_ERROR_NONE;
+
+ do {
+ error = maps_view_object_marker_get_image_file(object, &imgPath);
+ if (error != MAPS_ERROR_NONE || !imgPath) { break; }
+
+ img = evas_object_image_add(evas_object_evas_get(m_image));
+ evas_object_image_file_set(img, imgPath, nullptr);
+ int err = evas_object_image_load_error_get(img);
+ if (err != EVAS_LOAD_ERROR_NONE) {
+ MAPS_LOGE("Failed to load marker image file: %s", imgPath);
+ free(imgPath);
+ break;
+ }
+ free(imgPath);
+
+ evas_object_image_size_get(img, &imgWidth, &imgHeight);
+ imgSize = imgWidth * imgHeight * 4;
+
+ // Get Raw data pointer to the image
+ const unsigned char *srcData = (unsigned char *)evas_object_image_data_get(img, EINA_FALSE);
+ if (!srcData || imgSize <= 0) {
+ MAPS_LOGE("Failed to get image data from the evas image for the marker");
+ error = MAPS_ERROR_OUT_OF_MEMORY;
+ break;
+ }
+
+ imgData = (unsigned char *)malloc(imgSize);
+ if (!imgData) {
+ MAPS_LOGE("Failed to malloc!! for image data");
+ error = MAPS_ERROR_OUT_OF_MEMORY;
+ break;
+ }
+
+ // convert data from rgba to bgra
+ for (int i = 0; i < imgHeight; i++) {
+ for (int j = 0; j < imgWidth; j++) {
+ int offset = ((i * imgWidth) + j) * 4;
+ *(imgData + offset) = *(srcData + offset + 2);
+ *(imgData + offset + 1) = *(srcData + offset + 1);
+ *(imgData + offset + 2) = *(srcData + offset);
+ *(imgData + offset + 3) = *(srcData + offset + 3);
+ }
+ }
+ } while (0);
+
return (mapzen_error_e)convert_maps_error_to_mapzen_error(error);
}
maps_coordinates_h mapsCoord = nullptr;
double lat = 0.0, lng = 0.0;
int markerWidth = 0, markerHeight = 0;
+ int imgWidth = 0, imgHeight = 0;
int error = MAPS_ERROR_NONE;
+ unsigned char *imgData = nullptr;
+
+ const char* styleFormat = "{ style: 'points', color: white, size: [%fpx, %fpx], collide: false, anchor: %s, transition: { [show, hide]: { time: 0s } } }";
+
static std::string anchor;
- const char* styleFormat = "{ style: 'ux-icons-overlay', sprite: 'ux-search-active', size: [%dpx, %dpx], collide: false, anchor: %s, transition: { [show, hide]: { time: 0s } } }";
maps_view_marker_type_e type;
error = maps_view_object_marker_get_type(object, &type);
do {
if (error != MAPS_ERROR_NONE || type < MAPS_VIEW_MARKER_PIN || type > MAPS_VIEW_MARKER_STICKER) { break; }
+ error = getBitmapMarkerImage(object, imgData, imgWidth, imgHeight);
+
+ if (error != MAPS_ERROR_NONE || !imgData) {
+ MAPS_LOGE("Failed getting image data from marker object, with error code: %d", error);
+ break;
+ }
+ m_map->markerSetBitmap(tvMarker, imgWidth, imgHeight, reinterpret_cast<unsigned int *>(imgData));
+ free(imgData);
+
anchor = "center";
if (type == MAPS_VIEW_MARKER_PIN) {
anchor = "top";
}
+ float scaleFactor = 1.0/elm_config_scale_get();
error = maps_view_object_marker_get_size(object, &markerWidth, &markerHeight);
if (error != MAPS_ERROR_NONE) { break; }
- int sz = std::snprintf(nullptr, 0, styleFormat, markerWidth, markerHeight, anchor.c_str());
+ float scaledWidth = scaleFactor * markerWidth;
+ float scaledHeight = scaleFactor * markerHeight;
+
+ int sz = std::snprintf(nullptr, 0, styleFormat, scaledWidth, scaledHeight, anchor.c_str());
styleString.resize(sz+1);
- std::snprintf(&styleString[0], styleString.size(), styleFormat, markerWidth, markerHeight, anchor.c_str());
+ std::snprintf(&styleString[0], styleString.size(), styleFormat, scaledWidth, scaledHeight, anchor.c_str());
m_map->markerSetStyling(tvMarker, styleString.c_str());