Sha256: ec62b3ae93bf26119c3b6ab3ffeeb2c47ad78dd67cbae6e14e7ee2441079095a
Contents?: true
Size: 1.69 KB
Versions: 3
Compression:
Stored size: 1.69 KB
Contents
class @Location extends Backbone.View initElements : () -> @$map = @$el.find('.map') @$latitude = @$el.find('[data-location-attribute="latitude"]') @$longitude = @$el.find('[data-location-attribute="longitude"]') @$zoom = @$el.find('[data-location-attribute="zoom"]') initMap : () -> @_initMap() @_initLayer() @_initMarker() _initMap : () -> @center = [@$latitude.val(), @$longitude.val()] @map = L.map(@$map.attr('id')).setView(@center, @$zoom.val()) @map.on 'zoomend', (event) => @$zoom.val event.target.getZoom() _initLayer : () -> L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { attribution : '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors' }).addTo(@map) _initMarker : () -> marker = new L.marker @center, icon : L.icon iconUrl : '<%= asset_path('rademade_admin/leaflet/marker-icon.png') %>' shadowUrl : '<%= asset_path('rademade_admin/leaflet/marker-shadow.png') %>' iconSize : [25, 41] shadowSize : [41, 41] iconAnchor : [12, 41] shadowAnchor: [12, 41] draggable : true marker.on 'dragend', (event) => @_updateLatLng event.target.getLatLng() marker.addTo(@map) _updateLatLng : (latLng) -> @$latitude.val latLng.lat @$longitude.val latLng.lng @init : ($el) -> location = new this el : $el location.initElements() location.initMap() @initAll : () -> $('.location').each () -> $location = $(this) unless $location.data('initialized') Location.init $location $location.data('initialized', true) $ -> $(document).on('page:load ready init-plugins', Location.initAll)
Version data entries
3 entries across 3 versions & 1 rubygems