• Optimization
  • Navigation
  • Tracking
  • Maps
  • Places

Animate Map Style Layer

This example shows how to animate runtime map style layer.

  • Add Image Source layer

  • Update Image source every second


For all code examples, refer to Maps Code Examples

AnimateMapLayerViewController view source

2// AnimateMapLayerViewController.swift
3// maps-ios-demo
6import Foundation
7import UIKit
8import Nbmap
9class AnimateMapLayerViewController: UIViewController {
11 var nbMapView: NGLMapView! {
12 didSet {
13 oldValue?.removeFromSuperview()
14 if let mapView = nbMapView {
15 view.insertSubview(mapView, at: 0)
16 mapView.delegate = self
17 }
18 }

The main functionality of this example is to display a map view with an animated image overlay (radar images). The addImageSourceLayer() method sets up the image source and raster layer, and the updateAnimatedImageSource(_:) method is called periodically to update the image source with new radar images.

  1. Declaration and initialization of nbMapView, radarSuffix, and points variables.

  2. viewDidLoad() method where the nbMapView is created and added as a subview to the view.

  3. addImageSourceLayer() method to add an image source and raster layer to the map view.

  4. updateAnimatedImageSource(_:) method to update the image source with a new image.

  5. mapView(_:didFinishLoading:) delegate method that sets the initial center and zoom level of the map and calls addImageSourceLayer().

Have Questions ?