Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Ios #17

Closed
wants to merge 6 commits into from
Closed

Ios #17

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
/emscripten/main.js
/emscripten/main.js.map
/build
/xcode
*.sublime-*
*.sublime-*
41 changes: 13 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,24 @@
An OpenGL renderer for [Mapbox vector tiles](https://www.mapbox.com/blog/vector-tiles),
implemented in C++, targeting iOS & OSX.
iOS
===

# Build instructions
1. Make sure you have `xcode/llmr.xcodeproj`, which is a modified version of the OS X CMake-generated version.

## Mac OS X
1. Download & unpack Boost into `ios/boost_1_55_0`.

You may need to install [glfw3](http://www.glfw.org/docs/latest/):
1. This does some nasty things with exposing `map.transform` and hardcoding the shader preamble, but be not afraid.

```
brew install homebrew/versions/glfw3
```
1. Open, build, and run on simulator. Does not build for ARM yet.

```
mkdir xcode
cd xcode
cmake .. -G Xcode
```
### Gestures

Then open the xcode project and build.
* Pan to move.

* Pinch to zoom in or out (currently around map center, not gesture center).

# Style protobuf
* Double-tap to zoom in one level at gesture center.

We're encoding the styling information as a protocol buffer, according to
proto/style.proto. The reason for doing so is that we don't have to ship with a
JSON/yaml parser. To test the conversion script, run
* Two-finger single-tap to zoom out one level at gesture center.

```
bin/convert-style.js | protoc --decode=style proto/style.proto
```
* Rotate with two fingers to rotate map (currently around map center, not gesture center).

You should see a nicely formatted hierarchical output of the converted style.


# Usage

- Press 'R' to reset the transform
- Press 'N' to reset north
* Long-press to reset north as up.
9 changes: 5 additions & 4 deletions include/llmr/map/map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,20 @@ class Map {

void toggleDebug();

void update();

private:
bool findLoadedChildren(const Tile::ID& id, int32_t maxCoveringZoom, std::forward_list<Tile::ID>& retain);
bool findLoadedParent(const Tile::ID& id, int32_t minCoveringZoom, std::forward_list<Tile::ID>& retain);
void updateTiles();
Tile::Ptr addTile(const Tile::ID& id);
Tile::Ptr hasTile(const Tile::ID& id);


void update();

private:
public:
Settings& settings;
Transform transform;

private:
Style style;
Painter painter;

Expand Down
Binary file added ios/Icon-60.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ios/Icon-60@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ios/Icon-72.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ios/Icon-72@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ios/Icon-76.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ios/Icon-76@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ios/Icon-Small-50.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ios/Icon-Small-50@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ios/Icon-Small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ios/Icon-Small@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ios/Icon-Spotlight-40.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ios/Icon-Spotlight-40@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ios/Icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ios/Icon@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions ios/MBXAppDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// MBXAppDelegate.h
// ios
//
// Created by Justin R. Miller on 1/27/14.
//
//

#import <UIKit/UIKit.h>

@interface MBXAppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@end
24 changes: 24 additions & 0 deletions ios/MBXAppDelegate.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// MBXAppDelegate.m
// ios
//
// Created by Justin R. Miller on 1/27/14.
//
//

#import "MBXAppDelegate.h"

#import "MBXViewController.h"

@implementation MBXAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = [MBXViewController new];
[self.window makeKeyAndVisible];

return YES;
}

@end
21 changes: 21 additions & 0 deletions ios/MBXSettings.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// MBXSettings.hpp
// llmr
//
// Created by Justin R. Miller on 1/27/14.
//
//

#import <llmr/map/settings.hpp>

namespace llmr
{
class Settings_iOS : public Settings
{
public:
Settings_iOS();
virtual void save();
virtual void load();
virtual void clear();
};
}
68 changes: 68 additions & 0 deletions ios/MBXSettings.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
//
// MBXSettings.cpp
// llmr
//
// Created by Justin R. Miller on 1/27/14.
//
//

#import "MBXSettings.h"

#import <Foundation/Foundation.h>

using namespace llmr;

Settings_iOS::Settings_iOS() {
NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys:

// position
[NSNumber numberWithDouble:longitude], @"longitude",
[NSNumber numberWithDouble:latitude], @"latitude",
[NSNumber numberWithDouble:scale], @"scale",
[NSNumber numberWithDouble:angle], @"angle",

// debug
[NSNumber numberWithBool:debug], @"debug",

nil
];

[[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];
}

void Settings_iOS::load() {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

// position
longitude = [defaults doubleForKey:@"longitude"];
latitude = [defaults doubleForKey:@"latitude"];
scale = [defaults doubleForKey:@"scale"];
angle = [defaults doubleForKey:@"angle"];

// debug
debug = [defaults boolForKey:@"debug"];
}

void Settings_iOS::save() {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys:

// position
[NSNumber numberWithDouble:longitude], @"longitude",
[NSNumber numberWithDouble:latitude], @"latitude",
[NSNumber numberWithDouble:scale], @"scale",
[NSNumber numberWithDouble:angle], @"angle",

// debug
[NSNumber numberWithBool:debug], @"debug",

nil
];
// [defaults setPersistentDomain:appDefaults forName:[[NSBundle mainBundle] bundleIdentifier]];

// [defaults synchronize];
}

void Settings_iOS::clear() {
}
14 changes: 14 additions & 0 deletions ios/MBXViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// MBXViewController.h
// ios
//
// Created by Justin R. Miller on 1/27/14.
//
//

#import <GLKit/GLKit.h>
#import <UIKit/UIKit.h>

@interface MBXViewController : GLKViewController

@end
Loading