Sha256: e9ebe6e3988f3737214d3132d6b05ce6da5e3a3d7fc67c62c0e70382ec522bf0
Contents?: true
Size: 1.57 KB
Versions: 2
Compression:
Stored size: 1.57 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') %>' 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rademade_admin-0.1.3 | app/assets/javascripts/rademade_admin/app/common/location.coffee.erb |
rademade_admin-0.1.2 | app/assets/javascripts/rademade_admin/app/common/location.coffee.erb |