Code Monkey home page Code Monkey logo

mapbox-gl-ios-offline-example's Introduction

How to use this repository

  1. Clone or download as a ZIP
  2. Open Terminal, navigate to project folder and run
pod install
  1. Open OfflineMaps.xcworkspace
  2. Optional: Select team, if you want to run on device
  3. Run project

How to build a map source.

  1. Download Mapbox Studio Classic (https://www.mapbox.com/mapbox-studio-classic/#darwin)
  2. Create a new source
  3. Add some vector data (e.g. http://www.naturalearthdata.com)
  4. Save the project
  5. Go to settings -> Export to MBTiles
  6. Install mb-util (https://github.com/mapbox/mbutil)
  7. Convert MBTiles to PBF Files (More info https://github.com/klokantech/vector-tiles-sample)
mb-util --image_format=pbf countries.mbtiles countries
gzip -d -r -S .pbf *
find . -type f -exec mv '{}' '{}'.pbf \;
  1. Zip the folder

Structure of the style.json file

The Tiles-URL corresponds to your local server running on port 8080. The example zip file contains a top level folder countries. If you choose another zip structure or port, adjust the style.json.

"sources": {
        "composite": {
            "type": "vector",
            "tiles": ["http://localhost:8080/countries/{z}/{x}/{y}.pbf"]
        }
    }

The layers object is responsible for the styling of the map. The id is unique for every element. Source corresponds to the name in your sources object and the layer corresponds to the name of the layer in your source mbtiles file. For possible styles, use the MapBox Online Editor (http://www.mapbox.com) and download the style file.

"layers": [{
        "id": "background",
        "type": "background",
        "paint": {
            "background-color": "hsl(190, 67%, 47%)"
        }
    }, {
        "id": "countries",
        "type": "fill",
        "source": "composite",
        "source-layer": "countries",
        "layout": {
            "visibility": "visible"
        },
        "paint": {
            "fill-color": "hsl(0, 0%, 85%)",
            "fill-outline-color": "#F8E81C"
        }
    }, {
        "id": "countries-border",
        "type": "line",
        "source": "composite",
        "source-layer": "countries",
        "layout": {
            "visibility": "visible"
        },
        "paint": {
            "line-color": "#000000",
            "line-width": 1.2
        }
    }, {
        "id": "countries-deu",
        "type": "fill",
        "source": "composite",
        "source-layer": "countries",
        "filter": ["in", "ADM0_A3", "DEU"],
        "layout": {
            "visibility": "visible"
        },
        "paint": {
            "fill-color": "#BD0FE1"
        }
    }]

mapbox-gl-ios-offline-example's People

Contributors

jaysquared avatar

Watchers

 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.