Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example code for my DragMarkers project (part 3)
class App.Marker extends Spine.Model
@configure 'Marker', 'latitude', 'longitude', 'icon'
@extend Spine.Model.Ajax
constructor: ->
super
@gmarker = new google.maps.Marker(
position: new google.maps.LatLng(@latitude, @longitude)
icon: @icon
draggable: true
)
google.maps.event.addListener(@gmarker, 'dragend', (event) => @dragEnd(event))
google.maps.event.addListener(@gmarker, 'rightclick', (event) => @rightClick(event))
setMap: (map) -> @gmarker.setMap(map)
dragEnd: (event) ->
@updateAttributes({
latitude: @gmarker.getPosition().lat()
longitude: @gmarker.getPosition().lng()
})
rightClick: (event) ->
@gmarker.setMap(null)
@destroy()
rightClick: (event) ->
@gmarker.setMap(null)
@destroy()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.