Skip to content

Instantly share code, notes, and snippets.

View mousebird's full-sized avatar

Steve Gifford mousebird

View GitHub Profile
@mousebird
mousebird / gist:3472443
Created August 25, 2012 23:52
Who's using WhirlyGlobe and what for?
I'd like to know who's using WhirlyGlobe 1.2, 2.0 or the Component and what they're doing.
So speak up!
-Steve G
// Create an empty globe and tie it in to the view hierarchy
globeViewC = [[WhirlyGlobeViewController alloc] init];
globeViewC.delegate = self;
[self.view addSubview:globeViewC.view];
globeViewC.view.frame = self.view.bounds;
[self addChildViewController:globeViewC];
// This is a nice base layer with water and elevation, but no labels or boundaries
MaplyQuadEarthWithRemoteTiles *layer = [[MaplyQuadEarthWithRemoteTiles alloc] initWithBaseURL:@"http://a.tiles.mapbox.com/v3/mousebird.map-2ebn78d1/" ext:@"png" minZoom:0 maxZoom:12];
[globeViewC addLayer:layer];
// Let's start up over San Francisco, center of the universe
[globeViewC animateToPosition:MaplyCoordinateMakeWithDegrees(-122.4192, 37.7793) time:1.0];
// Let's start up over San Francisco, center of the universe
[globeViewC animateToPosition:MaplyCoordinateMakeWithDegrees(-122.4192, 37.7793) time:1.0];
- (void)globeViewController:(WhirlyGlobeViewController *)viewC didTapAt:(WGCoordinate)coord
{
// We need degrees for the query, even if we work in radians internally
float lat = coord.y * 180.0 / M_PI;
float lon = coord.x * 180.0 / M_PI;
// We want the geometry and a couple of attributes for just one feature under the point
NSString *account = @"mousebird";
NSString *admin0Table = @"table_10m_admin_0_map_subunits";
NSString *queryStr = [NSString stringWithFormat:
// Add an admin0 (country, basically) outline and label
- (void)addCountry:(MaplyVectorObject *)vecs
{
if (!vecs)
return;
// Add the the vectors to the globe with a line width a color and other parameters
[globeViewC addVectors:@[vecs] desc:
@{kMaplyColor: [UIColor whiteColor],kMaplyVecWidth: @(5.0),kMaplyDrawOffset: @(4.0),kMaplyFade: @(1.0)}];
// But hey, what about a label? Let's figure out where it should go.
MaplyPlateCarree *coordSys = [[MaplyPlateCarree alloc] initFullCoverage];
MaplyWMSTileSource *tileSource = [[MaplyWMSTileSource alloc] initWithBaseURL:@"http://raster.nationalmap.gov/ArcGIS/services/Orthoimagery/USGS_EDC_Ortho_NAIP/ImageServer/WMSServer" layers:@[@"0"] coordSys:coordSys minZoom:0 maxZoom:16 tileSize:256];
tileSource.transparent = true;
MaplyQuadEarthTilesLayer *layer = [[MaplyQuadEarthTilesLayer alloc] initWithCoordSystem:coordSys tileSource:tileSource];
layer.handleEdges = true;
layer.cacheDir = thisCacheDir;
[baseViewC addLayer:layer];
/* A wrapper around the data we need to draw a single
OpenGL ES related object.
*/
@interface SimpleGLObject : NSObject
// The buffer in OpenGL driver space containing the vertices
@property GLuint vertexBuffer;
// Vertex arrays contain the state to draw our object
@property GLuint vertexArray;
//
// ViewController.m
// NSMeetupExample
//
// Created by [email protected] on 8/6/13.
//
#import "ViewController.h"
#import "SimpleGLObject.h"
#import "FlexiVertexBuffer.h"
//
// SimpleGLObject.h
// NSMeetupExample
//
// Created by [email protected] on 8/6/13.
//
#import <UIKit/UIKit.h>
/* A wrapper around the data we need to draw a single