Git Product home page Git Product logo

geoswiftmapboxgl's Introduction

Build Status CocoaPods Compatible

GEOSwiftMapboxGL makes it easy generate annotations to display on MapboxGL. On each Geometry instance you can call one of the related convenience func mapboxShape(), that will return an annotation object ready to be added as annotations to a MGLMapView:

Features

  • A pure-Swift, type-safe, optional-aware programming interface
  • Automatically-typed geometry deserialization from WKT and WKB representations
  • MapboxGL integration
  • Quicklook integration
  • A lightweight GEOJSON parser
  • Extensively tested

Requirements

  • iOS 8.0+ / Mac OS X 10.10+
  • Xcode 8
  • Swift 3
  • CocoaPods 1.2.1+

Usage

Geometry creation

import GEOSwift
import Mapbox
import GEOSwiftMapboxGL

...

let point = Waypoint(WKT: "POINT(10 45)")!
let polygon = Geometry.create("POLYGON((35 10, 45 45.5, 15 40, 10 20, 35 10),(20 30, 35 35, 30 20, 20 30))")!

let annotations = [
    point.mapboxShape(),
    polygon.mapboxShape()
]
self.mapView.showAnnotations(annotations, animated: true)

...

GEOSwift and MapboxGL integration

Example:

let point = Waypoint(WKT: "POINT(10 45)")
let shape1 = point.mapboxShape() // will return a MGLPointAnnotation

let polygon = Geometry.create("POLYGON((35 10, 45 45.5, 15 40, 10 20, 35 10),(20 30, 35 35, 30 20, 20 30))")
let shape2 = polygon.mapboxShape() // Will return a MGLPolygon

In this table you can find which annotation class you should expect when calling mapboxShape() on a geometry:

WKT Feature GEOSwift class MapboxGL
POINT WayPoint MGLPointAnnotation
LINESTRING LineString MGLPolyline
POLYGON Polygon MGLPolygon
MULTIPOINT MultiPoint not supported
MULTILINESTRING MultiLineString not supported
MULTIPOLYGON MultiPolygon not supported
GEOMETRYCOLLECTION GeometryCollection MGLShapesCollection

Playground

TODO

Installation

Embedded frameworks require a minimum deployment target of iOS 8 or OS X Mavericks. GEOS is a configure/install project licensed under LGPL 2.1: it is difficult to build for iOS and its compatibility with static linking is at least controversial. Use of GEOSwiftMapboxGL without CocoaPods and with a project targeting iOS 7, even if possible, is advised against.

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. To install GEOSwiftMapboxGL with CocoaPods:

  • Make sure CocoaPods is installed (GEOSwiftMapboxGL requires version 1.2.1 or greater).

  • Update your Podfile to include the following:

use_frameworks!
pod 'GEOSwiftMapboxGL'
  • Run pod install.

NOTE: running pod install may cause some errors if your machine does not have autoconf, automake and glibtool, if you encounter those errors you can run brew install autoconf automake libtool to install those packages and run again pod install.

Creator

Andrea Cremaschi (@andreacremaschi)

License

  • GEOSwiftMapboxGL was released by Andrea Cremaschi (@andreacremaschi) under a MIT license. See LICENSE for more information.
  • GEOSwift was released by Andrea Cremaschi (@andreacremaschi) under a MIT license. See LICENSE for more information.
  • GEOS stands for Geometry Engine - Open Source, and is a C++ library, ported from the Java Topology Suite. GEOS implements the OpenGIS Simple Features for SQL spatial predicate functions and spatial operators. GEOS, now an OSGeo project, was initially developed and maintained by Refractions Research of Victoria, Canada.

geoswiftmapboxgl's People

Contributors

srgray avatar vfn avatar hugal31 avatar fedeojeda95 avatar

Stargazers

Thanos Bellos avatar

Watchers

 avatar

Forkers

thanosbellos

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.