   createMarkerSnapshot: (activeMarkerLayer) ->
     snapshot = {}
 
-    role = activeMarkerLayer?.getRole()
+    if activeMarkerLayer?
+      activeMarkerLayer = @getMarkerLayer(activeMarkerLayer.id)
+      role = activeMarkerLayer.getRole()
 
     for markerLayerId, markerLayer of @markerLayers when markerLayer.maintainHistory
       if role? and (markerLayer.getRole() is role) and (markerLayer isnt activeMarkerLayer)

    snapshot

  restoreFromMarkerSnapshot: (snapshot, activeMarkerLayer) ->
    role = activeMarkerLayer?.getRole()
    if role?
      # When snapshot includes multiple layerSnapshot of same `role`, disable snapshot restore target redirection
      # to avoid multiple layerSnapshot being restored to single markerLayer, its just confusing.
      layerSnapshotsOfSameRole = Object.keys(snapshot).filter (markerLayerId) =>
        @markerLayers[markerLayerId].getRole() is role
      if layerSnapshotsOfSameRole.length isnt 1
        role = null

    for markerLayerId, layerSnapshot of snapshot when markerLayer = @markerLayers[markerLayerId]
      if role? and markerLayer.getRole() is role
        activeMarkerLayer.restoreFromSnapshot(layerSnapshot, activeMarkerLayer isnt markerLayer)
      else
        markerLayer.restoreFromSnapshot(layerSnapshot)

  emitMarkerChangeEvents: (snapshot) ->
    if @transactCallDepth is 0

    @markerLayers = {}
    @markerLayers[@defaultMarkerLayer.id] = @defaultMarkerLayer
    @markerLayersWithPendingUpdateEvents = new Set()
    @markerLayerIdsByRole = {}
    @nextMarkerId = 1
    @outstandingSaveCount = 0
    @loadCount = 0
