From 6bc7705faf6fe1c2f48d4d46b0464e4bd35535f0 Mon Sep 17 00:00:00 2001 From: Matt Blair Date: Tue, 1 Nov 2016 17:24:53 -0400 Subject: [PATCH] This depends on Change 99078 to function correctly, please merge that first. Place marker view objects above all other map labels - There is a known issue where markers are temporarily incorrectly sized after changing map styles - Use 'sdk-point-overlay' style for markers - Remove the 'texture' parameter from 'sdk-point-overlay' at scene load time so that custom bitmaps can be used instead of the sprite sheet - Clean up the tangram_view_type enum - Use 'setMapType' in 'TangramView::create' to start loading the initial scene Change-Id: Ie5a15448e0dd86463d565f014f7c9de543707735 --- src/mapzen/mapzen_types.h | 4 +--- src/mapzen/mapzen_util.c | 10 ++++------ src/mapzen/tangram_view.cpp | 10 ++++++++-- src/mapzen/tangram_view.hpp | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/mapzen/mapzen_types.h b/src/mapzen/mapzen_types.h index 6023bf8..6c64776 100644 --- a/src/mapzen/mapzen_types.h +++ b/src/mapzen/mapzen_types.h @@ -115,9 +115,7 @@ typedef enum { typedef enum { TANGRAM_VIEW_NORMAL = 0, TANGRAM_VIEW_TERRAIN, - TANGRAM_VIEW_SATELLITE, - TANGRAM_VIEW_HYBRID, - TANGRAM_VIEW_NOT_SUPPORTED + TANGRAM_VIEW_NONE } tangram_view_type; typedef struct { diff --git a/src/mapzen/mapzen_util.c b/src/mapzen/mapzen_util.c index 9128a10..a7eca38 100644 --- a/src/mapzen/mapzen_util.c +++ b/src/mapzen/mapzen_util.c @@ -203,8 +203,6 @@ int convert_tangram_view_type_to_maps_view_type(int maps_view_type) switch (maps_view_type) { case TANGRAM_VIEW_NORMAL: return MAPS_VIEW_TYPE_NORMAL; case TANGRAM_VIEW_TERRAIN: return MAPS_VIEW_TYPE_TERRAIN; - case TANGRAM_VIEW_SATELLITE: /*NOT SUPPORTED BY TANGRAM*/ - case TANGRAM_VIEW_HYBRID: /*NOT SUPPORTED BY TANGRAM*/ default: return MAPS_VIEW_TYPE_NORMAL; } } @@ -212,10 +210,10 @@ int convert_tangram_view_type_to_maps_view_type(int maps_view_type) int convert_maps_view_type_to_tangram_view_type(int maps_view_type) { switch (maps_view_type) { - case MAPS_VIEW_TYPE_NORMAL: return TANGRAM_VIEW_NORMAL; - case MAPS_VIEW_TYPE_SATELLITE: return TANGRAM_VIEW_NOT_SUPPORTED; + case MAPS_VIEW_TYPE_NORMAL: return TANGRAM_VIEW_NORMAL; + case MAPS_VIEW_TYPE_SATELLITE: return TANGRAM_VIEW_NONE; case MAPS_VIEW_TYPE_TERRAIN: return TANGRAM_VIEW_TERRAIN; - case MAPS_VIEW_TYPE_HYBRID: return TANGRAM_VIEW_NOT_SUPPORTED; - default: return TANGRAM_VIEW_NORMAL; + case MAPS_VIEW_TYPE_HYBRID: return TANGRAM_VIEW_NONE; + default: return TANGRAM_VIEW_NONE; } } diff --git a/src/mapzen/tangram_view.cpp b/src/mapzen/tangram_view.cpp index b241d28..51bd130 100644 --- a/src/mapzen/tangram_view.cpp +++ b/src/mapzen/tangram_view.cpp @@ -127,7 +127,9 @@ mapzen_error_e TangramView::create(maps_view_h view, maps_plugin_map_view_ready_ MAPS_LOGD("evas_gl_context_create() set PixelScale %f", scaleFactor); m_map->setPixelScale(scaleFactor); - m_map->loadSceneAsync(NORMAL_SCENE_FILE_PATH, false, sceneLoadedCb, (void*)view); + // Start loading the scene by setting the map type. + setMapType(view); + if (providerKey) { m_providerKey = providerKey; } @@ -618,7 +620,7 @@ mapzen_error_e TangramView::updateMarker(maps_view_object_h object, Tangram::Mar 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 } } }"; + const char* styleFormat = "{ style: 'sdk-point-overlay', color: white, size: [%fpx, %fpx], collide: false, anchor: %s, transition: { [show, hide]: { time: 0s } } }"; static std::string anchor; @@ -876,6 +878,10 @@ void TangramView::setMapType(maps_view_h view) m_viewType = newViewType; m_map->loadSceneAsync(newSceneFile, false, sceneLoadedCb, (void*)view); m_isProviderKeySet = false; + + // When the scene is changed, update the 'sdk-point-overlay' style to remove it's texture; + // this allows us to use this style for markers with custom bitmaps. + m_map->queueSceneUpdate("styles.sdk-point-overlay.texture", "null"); } bool buildings_enabled = false; diff --git a/src/mapzen/tangram_view.hpp b/src/mapzen/tangram_view.hpp index 51dafdb..395ad6e 100644 --- a/src/mapzen/tangram_view.hpp +++ b/src/mapzen/tangram_view.hpp @@ -115,7 +115,7 @@ private: std::mutex m_viewObjectMutex; maps_plugin_map_view_ready_cb m_readyCb = nullptr; - tangram_view_type m_viewType = TANGRAM_VIEW_NORMAL; + tangram_view_type m_viewType = TANGRAM_VIEW_NONE; MapViewObjects m_mapViewObjs; //current set of map objects }; -- 2.7.4