MapGL 0.1.8

MapGL 0.1.8

Maintained by Eugene Tyutyuev, Alexander Volokhin.

MapGL 0.1.8

  • By
  • Alexander Volokhin and Eugene Tyutyuev



2GIS Maps SDK for iOS.


Get Access

As a first step to use MapGL you need to get the access key (contact us [email protected] if you need one).

Creating the Map

To show the map you should first create MapView object. It is a custom UIView so you can create it using XIB, Storyboard or in code.

let map = MapView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))

Showing the Map with default center and zoom "Your API access key")

Showing the Map with custom center and zoom
  apiKey: "Your API access key",
  center: CLLocationCoordinate2D(latitude: 25.23584, longitude: 55.31878),
  zoom: 16

Showing the Marker with default image

All manipulations with the map is allowed after the show(apiKey:) method is completed. "apiKey") { _ in
  let marker = Marker(coordinates: map.mapCenter)

Showing the Marker with custom image

let marker = Marker(
  coordinates: CLLocationCoordinate2D(latitude: 25.23584, longitude: 55.31878),
  image: UIImage(named: "pin")!,
  anchor: .bottom

Showing the Circle

let circle = Circle(
  center: CLLocationCoordinate2D(latitude: 25.23584, longitude: 55.31878),
  radius: 500,
  strokeColor: .red,
  strokeWidth: 5,
  fillColor: UIColor.lightGray.withAlphaComponent(0.5)

Showing the Polygon

let polygon = Polygon(
  points: [
    CLLocationCoordinate2D(latitude: 25.20, longitude: 55.4478),
    CLLocationCoordinate2D(latitude: 25.20, longitude: 55.4878),
    CLLocationCoordinate2D(latitude: 25.24584, longitude: 55.31878),
  strokeColor: .red,
  strokeWidth: 5,

Showing the Polyline

let polyline = Polyline(
  points: [
    CLLocationCoordinate2D(latitude: 25.30, longitude: 55.378),
    CLLocationCoordinate2D(latitude: 25.20, longitude: 55.378),
  style1: PolylineStyle(color: .red, width: 5),
  style2: PolylineStyle(color: .green, width: 9),
  style3: PolylineStyle(color: .blue, width: 13)

Showing the Label

let label = Label(
  center: CLLocationCoordinate2D(latitude: 25.30, longitude: 55.378),
  color: .red,
  text: "Demo label",
  fontSize: 24

Selecting the building, road and others objects on map

let entity = MapEntity(
  id: "13933647002609599"

Receiving Map Click Events

map.mapClick = { coordinates in
  // Do smth with map click coordinates

Receiving Object Click Events

func mapView(_ mapView: MapView, didSelectObject object: MapObject) {
  // do smth with object

Show route on map

To get directions API key please visit or contact [email protected]

let directions = map.makeDirections(with: "Your directions api key")
directions.showCarRoute(points: [
  CLLocationCoordinate2D(latitude: 25.20, longitude: 55.4878),
  CLLocationCoordinate2D(latitude: 25.20, longitude: 55.5278),

Hide route from map


Hiding and showing objects

Some objects (Marker, Label, Building) can be shown/hidden via .show() or .hide() method


To run the example project, clone the repo, and run pod install from the Example directory.


MapGL is available through CocoaPods. To install it, simply add the following line to your Podfile.

pod 'MapGL'


MapGL is available under the BSD 2-Clause "Simplified" license. See the LICENSE file for more info.