summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjmkiley <jordan.kiley@mapbox.com>2017-04-05 16:35:08 -0700
committerjmkiley <jordan.kiley@mapbox.com>2017-04-13 14:58:40 -0700
commit795f6e07d31f9146addf2eddbaf2294c3a2a47fe (patch)
tree047ec78cc516a27011c45e76e4a214e91da0fe72
parent9340b4822a9d5f43952ba71ff16315d606de50bc (diff)
downloadqtlocation-mapboxgl-795f6e07d31f9146addf2eddbaf2294c3a2a47fe.tar.gz
debugging stuff
-rw-r--r--platform/ios/app/LimeGreenStyleLayer.h13
-rw-r--r--platform/ios/app/LimeGreenStyleLayer.m61
-rw-r--r--platform/ios/app/MBXViewController.m19
-rw-r--r--platform/ios/ios.xcodeproj/project.pbxproj6
4 files changed, 99 insertions, 0 deletions
diff --git a/platform/ios/app/LimeGreenStyleLayer.h b/platform/ios/app/LimeGreenStyleLayer.h
new file mode 100644
index 0000000000..f2fa9852e2
--- /dev/null
+++ b/platform/ios/app/LimeGreenStyleLayer.h
@@ -0,0 +1,13 @@
+//
+// LimeGreenStyleLayer.h
+// ios
+//
+// Created by Jordan Kiley on 4/5/17.
+// Copyright © 2017 Mapbox. All rights reserved.
+//
+
+#import <Mapbox/Mapbox.h>
+
+@interface LimeGreenStyleLayer : MGLOpenGLStyleLayer
+
+@end
diff --git a/platform/ios/app/LimeGreenStyleLayer.m b/platform/ios/app/LimeGreenStyleLayer.m
new file mode 100644
index 0000000000..1eaabd9c09
--- /dev/null
+++ b/platform/ios/app/LimeGreenStyleLayer.m
@@ -0,0 +1,61 @@
+#import "LimeGreenStyleLayer.h"
+//
+#include <OpenGLES/ES3/gl.h>
+#include <OpenGLES/ES3/glext.h>
+//#include <MGLOpenGLStyleLayer.h>
+@implementation LimeGreenStyleLayer {
+ GLuint _program;
+ GLuint _vertexShader;
+ GLuint _fragmentShader;
+ GLuint _buffer;
+ GLuint _aPos;
+}
+
+- (void)didMoveToMapView:(MGLMapView *)mapView {
+ static const GLchar *vertexShaderSource = "attribute vec2 a_pos; void main() { gl_Position = vec4(a_pos, 0, 1); }";
+ static const GLchar *fragmentShaderSource = "void main() { gl_FragColor = vec4(0, 0, 1, 1); }";
+
+ _program = glCreateProgram();
+ _vertexShader = glCreateShader(GL_VERTEX_SHADER);
+ _fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
+
+ glShaderSource(_vertexShader, 1, &vertexShaderSource, NULL);
+ glCompileShader(_vertexShader);
+ glAttachShader(_program, _vertexShader);
+ glShaderSource(_fragmentShader, 1, &fragmentShaderSource, NULL);
+ glCompileShader(_fragmentShader);
+ glAttachShader(_program, _fragmentShader);
+ glLinkProgram(_program);
+ _aPos = glGetAttribLocation(_program, "a_pos");
+ GLfloat background[] = { -1,-1, 1,-1, -1,1, 1,1 };
+ glGenBuffers(1, &_buffer);
+ glBindBuffer(GL_ARRAY_BUFFER, _buffer);
+ glBufferData(GL_ARRAY_BUFFER, 8 * sizeof(GLfloat), background, GL_STATIC_DRAW);
+}
+
+- (void)drawInMapView:(MGLMapView *)mapView withContext:(MGLStyleLayerDrawingContext)context {
+ glUseProgram(_program);
+ glBindBuffer(GL_ARRAY_BUFFER, _buffer);
+ glEnableVertexAttribArray(_aPos);
+ glVertexAttribPointer(_aPos, 2, GL_FLOAT, GL_FALSE, 0, NULL);
+ glDisable(GL_STENCIL_TEST);
+// glDisable(GL_DEPTH_TEST);
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+ glEnable(GL_DEPTH_TEST);
+ glDepthFunc(GL_ALWAYS);
+}
+
+- (void)willMoveFromMapView:(MGLMapView *)mapView {
+ if (!_program) {
+ return;
+ }
+
+ glDeleteBuffers(1, &_buffer);
+ glDetachShader(_program, _vertexShader);
+ glDetachShader(_program, _fragmentShader);
+ glDeleteShader(_vertexShader);
+ glDeleteShader(_fragmentShader);
+ glDeleteProgram(_program);
+}
+
+@end
diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m
index a7bab2108a..890427e2c1 100644
--- a/platform/ios/app/MBXViewController.m
+++ b/platform/ios/app/MBXViewController.m
@@ -11,6 +11,8 @@
#import <objc/runtime.h>
+#import "LimeGreenStyleLayer.h"
+
static const CLLocationCoordinate2D WorldTourDestinations[] = {
{ .latitude = 38.9131982, .longitude = -77.0325453144239 },
{ .latitude = 37.7757368, .longitude = -122.4135302 },
@@ -1821,6 +1823,23 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
// that a device with an English-language locale is already effectively
// using locale-based country labels.
_usingLocaleBasedCountryLabels = [[self bestLanguageForUser] isEqualToString:@"en"];
+
+ LimeGreenStyleLayer *layer = [[LimeGreenStyleLayer alloc] initWithIdentifier:@"mbx-custom"];
+ MGLStyleLayer *symbolLayer = [style layerWithIdentifier:@"admin-3-4-boundaries"];
+
+ [style insertLayer:layer belowLayer:symbolLayer];
+
+ NSURL *url = [NSURL URLWithString:@"mapbox://examples.69ytlgls"];
+
+ MGLVectorSource *source = [[MGLVectorSource alloc] initWithIdentifier:@"state-source" configurationURL:url];
+ [style addSource:source];
+
+ MGLFillStyleLayer *fillLayer = [[MGLFillStyleLayer alloc] initWithIdentifier:@"states" source:source];
+ fillLayer.sourceLayerIdentifier = @"stateData_2-dx853g";
+ fillLayer.fillColor = [MGLStyleValue valueWithRawValue:[UIColor redColor]];
+ // [style addLayer:fillLayer];
+ [style insertLayer:fillLayer aboveLayer:layer];
+// NSLog(@"%@", style.layers);
}
- (void)mapViewRegionIsChanging:(MGLMapView *)mapView
diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj
index 9936c7244f..94f976b981 100644
--- a/platform/ios/ios.xcodeproj/project.pbxproj
+++ b/platform/ios/ios.xcodeproj/project.pbxproj
@@ -130,6 +130,7 @@
35E79F201D41266300957B9E /* MGLStyleLayer_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 35E79F1F1D41266300957B9E /* MGLStyleLayer_Private.h */; };
35E79F211D41266300957B9E /* MGLStyleLayer_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 35E79F1F1D41266300957B9E /* MGLStyleLayer_Private.h */; };
36F1153D1D46080700878E1A /* libmbgl-core.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 36F1153B1D46080700878E1A /* libmbgl-core.a */; };
+ 3EA8545B1E955EEF00D716EE /* LimeGreenStyleLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 3EA8545A1E955EEF00D716EE /* LimeGreenStyleLayer.m */; };
400533011DB0862B0069F638 /* NSArray+MGLAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 400532FF1DB0862B0069F638 /* NSArray+MGLAdditions.h */; };
400533021DB0862B0069F638 /* NSArray+MGLAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 400533001DB0862B0069F638 /* NSArray+MGLAdditions.mm */; };
400533031DB086490069F638 /* NSArray+MGLAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 400533001DB0862B0069F638 /* NSArray+MGLAdditions.mm */; };
@@ -608,6 +609,8 @@
35E79F1F1D41266300957B9E /* MGLStyleLayer_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLStyleLayer_Private.h; sourceTree = "<group>"; };
36F1153B1D46080700878E1A /* libmbgl-core.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libmbgl-core.a"; path = "build/Debug-iphoneos/libmbgl-core.a"; sourceTree = "<group>"; };
36F1153C1D46080700878E1A /* libmbgl-platform-ios.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libmbgl-platform-ios.a"; path = "build/Debug-iphoneos/libmbgl-platform-ios.a"; sourceTree = "<group>"; };
+ 3EA854591E955EEF00D716EE /* LimeGreenStyleLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LimeGreenStyleLayer.h; sourceTree = "<group>"; };
+ 3EA8545A1E955EEF00D716EE /* LimeGreenStyleLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LimeGreenStyleLayer.m; sourceTree = "<group>"; };
400532FF1DB0862B0069F638 /* NSArray+MGLAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+MGLAdditions.h"; sourceTree = "<group>"; };
400533001DB0862B0069F638 /* NSArray+MGLAdditions.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "NSArray+MGLAdditions.mm"; sourceTree = "<group>"; };
4018B1C31CDC277F00F666AF /* MGLAnnotationView_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLAnnotationView_Private.h; sourceTree = "<group>"; };
@@ -1144,6 +1147,8 @@
354B839B1D2E9B48005D9406 /* MBXUserLocationAnnotationView.m */,
DA1DC9681CB6C6B7006E619F /* MBXOfflinePacksTableViewController.h */,
DA1DC9691CB6C6B7006E619F /* MBXOfflinePacksTableViewController.m */,
+ 3EA854591E955EEF00D716EE /* LimeGreenStyleLayer.h */,
+ 3EA8545A1E955EEF00D716EE /* LimeGreenStyleLayer.m */,
DA1DC9531CB6C1C2006E619F /* MBXViewController.h */,
DA1DC99A1CB6E064006E619F /* MBXViewController.m */,
632281DD1E6F855900D75A5D /* MBXEmbeddedMapViewController.h */,
@@ -2097,6 +2102,7 @@
DA1DC96B1CB6C6B7006E619F /* MBXOfflinePacksTableViewController.m in Sources */,
DA1DC96A1CB6C6B7006E619F /* MBXCustomCalloutView.m in Sources */,
DA1DC99B1CB6E064006E619F /* MBXViewController.m in Sources */,
+ 3EA8545B1E955EEF00D716EE /* LimeGreenStyleLayer.m in Sources */,
40FDA76B1CCAAA6800442548 /* MBXAnnotationView.m in Sources */,
632281DF1E6F855900D75A5D /* MBXEmbeddedMapViewController.m in Sources */,
);