diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2015-06-11 13:57:33 -0400 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2015-06-11 17:26:37 -0400 |
commit | 2435c1ad2603432186ee61eb4c423244a088bc51 (patch) | |
tree | 2377c2af37ef8c5ed21e1cf94c916141ebd57d7d /platform | |
parent | f46328655e027bf490692fcde4aab770912aac8d (diff) | |
download | qtlocation-mapboxgl-2435c1ad2603432186ee61eb4c423244a088bc51.tar.gz |
use array of structs rather than parallel arrays for annotations
Diffstat (limited to 'platform')
-rw-r--r-- | platform/default/glfw_view.cpp | 9 | ||||
-rw-r--r-- | platform/ios/MGLMapView.mm | 14 |
2 files changed, 9 insertions, 14 deletions
diff --git a/platform/default/glfw_view.cpp b/platform/default/glfw_view.cpp index 0f063e5925..e9da752909 100644 --- a/platform/default/glfw_view.cpp +++ b/platform/default/glfw_view.cpp @@ -1,3 +1,4 @@ +#include <mbgl/annotation/point_annotation.hpp> #include <mbgl/platform/default/glfw_view.hpp> #include <mbgl/platform/gl.hpp> #include <mbgl/platform/log.hpp> @@ -130,8 +131,7 @@ void GLFWView::onKey(GLFWwindow *window, int key, int /*scancode*/, int action, } void GLFWView::addRandomPointAnnotations(int count) { - std::vector<mbgl::LatLng> points; - std::vector<std::string> markers; + std::vector<mbgl::PointAnnotation> points; const auto sw = map->latLngForPixel({ 0, 0 }); const auto ne = map->latLngForPixel({ double(width), double(height) }); @@ -140,11 +140,10 @@ void GLFWView::addRandomPointAnnotations(int count) { const double lon = sw.longitude + (ne.longitude - sw.longitude) * (double(std::rand()) / RAND_MAX); const double lat = sw.latitude + (ne.latitude - sw.latitude) * (double(std::rand()) / RAND_MAX); - points.push_back({ lat, lon }); - markers.push_back("default_marker"); + points.emplace_back(mbgl::LatLng{ lat, lon }, "default_marker"); } - map->addPointAnnotations(points, markers); + map->addPointAnnotations(points); } void GLFWView::onScroll(GLFWwindow *window, double /*xOffset*/, double yOffset) { diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index f9318f067b..d4c26d6c9f 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -8,6 +8,7 @@ #import <OpenGLES/EAGL.h> #include <mbgl/mbgl.hpp> +#include <mbgl/annotation/point_annotation.hpp> #include <mbgl/platform/platform.hpp> #include <mbgl/platform/darwin/reachability.h> #include <mbgl/storage/default_file_source.hpp> @@ -1669,11 +1670,8 @@ CLLocationCoordinate2D MGLLocationCoordinate2DFromLatLng(mbgl::LatLng latLng) { if ( ! annotations) return; - std::vector<mbgl::LatLng> latLngs; - latLngs.reserve(annotations.count); - - std::vector<std::string> symbols; - symbols.reserve(annotations.count); + std::vector<mbgl::PointAnnotation> points; + points.reserve(annotations.count); BOOL delegateImplementsSymbolLookup = [self.delegate respondsToSelector:@selector(mapView:symbolNameForAnnotation:)]; @@ -1681,8 +1679,6 @@ CLLocationCoordinate2D MGLLocationCoordinate2DFromLatLng(mbgl::LatLng latLng) { assert([annotation conformsToProtocol:@protocol(MGLAnnotation)]); - latLngs.push_back(MGLLatLngFromLocationCoordinate2D(annotation.coordinate)); - NSString *symbolName = nil; if (delegateImplementsSymbolLookup) @@ -1690,10 +1686,10 @@ CLLocationCoordinate2D MGLLocationCoordinate2DFromLatLng(mbgl::LatLng latLng) symbolName = [self.delegate mapView:self symbolNameForAnnotation:annotation]; } - symbols.push_back((symbolName ? [symbolName UTF8String] : "")); + points.emplace_back(MGLLatLngFromLocationCoordinate2D(annotation.coordinate), (symbolName ? [symbolName UTF8String] : "")); } - std::vector<uint32_t> annotationIDs = _mbglMap->addPointAnnotations(latLngs, symbols); + std::vector<uint32_t> annotationIDs = _mbglMap->addPointAnnotations(points); for (size_t i = 0; i < annotationIDs.size(); ++i) { |