Skip to content

Instantly share code, notes, and snippets.

View mousebird's full-sized avatar

Steve Gifford mousebird

View GitHub Profile
nasaLayers =
[{
name: "Mapbox Satellite",
url: "http://a.tiles.mapbox.com/v3/examples.map-zyt2v9k2.json",
base: true
},
{ name: "MODIS/Terra TrueColor",
url: "http://map1.vis.earthdata.nasa.gov/wmts-webmerc/MODIS_Terra_CorrectedReflectance_TrueColor/default/{Time}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.jpg",
minzoom: 1,
maxzoom: 9,
@mousebird
mousebird / MarkerCluster.m
Last active October 4, 2019 21:32
Marker Cluster Example
NSMutableArray *markers = [NSMutableArray array];
UIImage *pinImage = [UIImage imageNamed:@"map_pin"];
// Work through the locations
for (unsigned int ii=0;ii<howMany;ii++)
{
LocationInfo *location = &locations[ii];
MaplyScreenMarker *marker = [[MaplyScreenMarker alloc] init];
marker.image = pinImage;
@mousebird
mousebird / bngCoordSys.swift
Created March 10, 2016 21:54
Custom British National Grid projection
let proj4Str = "+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +units=m +no_defs"
let coordSys = MaplyProj4CoordSystem(string: proj4Str)
var bbox = MaplyBoundingBox()
bbox.ll.x = 1393.0196
bbox.ll.y = 12494.9764
bbox.ur.x = 671196.3657
bbox.ur.y = 1230275.0454
coordSys.setBounds(bbox)
/** @brief Interpolate a new state between the given states A and B.
@details This does a simple interpolation (lat/lon, not great circle) between the two animation states.
*/
+ (nonnull WhirlyGlobeViewControllerAnimationState *)Interpolate:(double)t from:(WhirlyGlobeViewControllerAnimationState *__nonnull)stateA to:(WhirlyGlobeViewControllerAnimationState *__nonnull)stateB;
func insertClusteredMarkers(compB : NSArray, theBaseView: MaplyBaseViewController) {
let size = CGSizeMake(32, 32)
let image = UIImage (named: "alcohol-shop-24@2x")
var markers = [MaplyScreenMarker]()
for object in compB {
let marker = MaplyScreenMarker()
marker.image = image
marker.loc = (object as! MaplyVectorObject).center()
marker.size = size
marker.userObject = object.userObject
func insertClusteredMarkers(compB : NSArray, theBaseView: MaplyBaseViewController) {
let size = CGSizeMake(32, 32)
let image = UIImage (named: "alcohol-shop-24@2x")
var markers = [MaplyScreenMarker]()
for object in compB {
let marker = MaplyScreenMarker()
marker.image = image
marker.loc = (object as! MaplyVectorObject).center()
marker.size = size
marker.userObject = object.userObject
func createLayer(baseView: MaplyBaseViewController) -> (MaplyQuadImageTilesLayer) {
let precipTileSource = MaplyMultiplexTileSource(sources: tileSources)
// Create a precipitation layer that animates
let precipLayer = MaplyQuadImageTilesLayer(tileSource: precipTileSource!)
precipLayer?.imageDepth = UInt32(tileSources.count)
precipLayer?.animationPeriod = 1.0
precipLayer?.imageFormat = MaplyQuadImageFormat.ImageUByteRed
precipLayer?.numSimultaneousFetches = 4
precipLayer?.handleEdges = false
precipLayer?.coverPoles = false
// A test case that displays an animated weather layer on top of
// the standard Geography Class basemap.
// This is part of the AutoTester in the WhirlyGlobe-Maply repo.
class AnimatedBasemapTestCase: MaplyTestCase {
// Use Geography Class as the base layer
let geographyClass = GeographyClassTestCase()
let cacheDir = NSSearchPathForDirectoriesInDomains(.CachesDirectory, .UserDomainMask, true)[0]
var tileSources = [MaplyRemoteTileInfo]()
pod 'WhirlyGlobe', :http => 'https://s3-us-west-1.amazonaws.com/whirlyglobemaplydistribution/iOS_daily_builds/WhirlyGlobe-Maply_Nightly_latest.zip'
// Set up a cache directory
String cacheDirName = "stamen_watercolor";
File cacheDir = new File(getActivity().getCacheDir(), cacheDirName);
cacheDir.mkdir();
// Set up the a remote tile source and point it at Stamen Watercolor
RemoteTileSource remoteTileSource = new RemoteTileSource(new RemoteTileInfo("http://tile.stamen.com/watercolor/", "png", 0, 18));
remoteTileSource.setCacheDir(cacheDir);
QuadImageTileLayer baseLayer = new QuadImageTileLayer(baseController, new SphericalMercatorCoordSystem(), remoteTileSource);