Giter Club home page Giter Club logo

os-mapbox-adapter's Introduction

Mapbox Adapter for OS Maps API

This is a simple NSURLProtocol subclass to provide a style json file that loads the Ordnance Survey Maps API in to Mapbox GL.

Getting Started

You will need an API key from Ordnance Survey to use this sample.

printf "your-api-key" > APIKEY

Please ensure your APIKEY file doesn't have a trailing new line.

You will also need to download the latest Mapbox framework. At time of writing, Mapbox doesn't support Carthage, so installing the Mapbox framework is either a manual process or requires CocoaPods.

Using in your own project

Easiest way to use this framework is using carthage. Add

github "OrdnanceSurvey/os-mapbox-adapter"

to your Cartfile

OSMapboxAdapter.framework

This framework contains a single public class, OSMapsAPI. There are two methods to this class, setAPIKey:, which you should call with your OS Maps API key before trying to use it, and stylesheetURLForProduct: which you should pass the result of to your map view:

[OSMapsAPI setAPIKey:"my-api-key"];
self.mapView.styleURL = [OSMapsAPI stylesheetURLForProduct:OSBaseMapStyleRoad];

How it works

To enable the protocol to be picked up by Mapbox's private NSURLSession, there's a method swizzle in here to override +[NSURLSessionConfiguration defaultSessionConfiguration] and return a version with OSMapsStyleProtocol inserted in the configuration's protocolClasses property. If you'd rather not use method swizzling, you could alternatively ship a style file as an asset in your app. There is a template available here and you simply need to add a URL template to the tiles array following the OS Maps documentation

OSBaseMapStyle

The product options available. These products look like the tiles below:

OSBaseMapStyleRoad
Sample Road Tile

OSBaseMapStyleOutdoor
Sample Outdoor Tile

OSBaseMapStyleLight
Sample Light Tile

OSBaseMapStyleNight
Sample Night Tile

Limiting the map view to the bounds of the UK

The Mapbox SDK doesn't currently support limiting the map to the bounds of the UK, however there are issues being tracked on GitHub so this will hopefully be available soon. See #3602 and #2457 and #2341.

License

This framework is released under the Apache 2.0 License The Mapbox SDK is released under the BSD License

os-mapbox-adapter's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.