Sha256: 3781b00a9330c12835c080a31bb33c47b099408d54476c8792e6a9b02536f32b

Contents?: true

Size: 1.68 KB

Versions: 1

Compression:

Stored size: 1.68 KB

Contents

class ADF.Map.Models.Map extends Backbone.Model

  overlays: []
  clustered_overlays: []

  maxZoomLevelForClustering: 21
  maxZoomOnClick: 18

  defaults:
    center: new google.maps.LatLng(57,25)
    zoom: 7
    mapTypeId: google.maps.MapTypeId.HYBRID
    mapTypeControl: false
    zoomControl: true
    zoomControlOptions:
      style: google.maps.ZoomControlStyle.SMALL
      position: google.maps.ControlPosition.RIGHT_TOP
    panControl: false
    streetViewControl: false

  clusterDefaults:
    "maxZoom": 21
    "maxZoomOnClick": 21
    "clusterShowType": "chart"

  constructor: (options, clusterOptions) ->
    super(options)
    @clusterOptions = $.extend(@clusterDefaults, clusterOptions)
    
  initGMap: (mapElement) ->
    @map = new google.maps.Map(document.getElementById(mapElement), @attributes)
    @markerClusterer = new ADF.Cluster.Views.MarkerClusterer(@map, null, @clusterOptions)
    return @map

  getGMap: () ->
    return @map

  addOverlay: (overlay, clustering = false) ->
    @overlays.push(overlay)
    @clusterOverlay(overlay) if clustering || overlay.isClustering()

  setCenter: (latLng) ->
    @map.setCenter(latLng)
    
  hideZoomControl: () ->
    @map.setOptions({zoomControl: false})
    
  showZoomControl: () ->
    @map.setOptions({zoomControl: true})
    
  fitBounds: (bounds) ->
    @map.fitBounds(bounds)

  clearMap: () ->
    for overlay in @overlays
      overlay.marker.setMap(null) if overlay.marker?
      overlay.setMap(null)
      @markerClusterer.removeMarker(overlay) if @markerClusterer && overlay.isClustering()
    @overlays = []
    @markerClusterer.clearMarkers()

  clusterOverlay: (overlay) ->
    @markerClusterer.addMarker(overlay) if @markerClusterer

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
socmap_adf-0.0.1 lib/assets/javascripts/socmap_adf/modules/map/models/map.js.coffee