Skip to content

Instantly share code, notes, and snippets.

@ptn
Created July 30, 2012 00:58
Show Gist options
  • Save ptn/3203064 to your computer and use it in GitHub Desktop.
Save ptn/3203064 to your computer and use it in GitHub Desktop.
class MapManager
constructor: ->
path = @buildPath()
map = new GMaps
div: "#map"
lat: -10
lng: -76
zoom: 6
idle: ->
map.refresh()
@map = map
@map.drawPolyline
path: path
strokeColor: '#476D00'
strokeOpacity: 0.6
strokeWeight: 6
$.each path, (_, coord) =>
@stopBy(coord)
@map.drawOverlay
lat: path[0][0]
lng: path[0][1]
content: '<div class="map-overlay">Inicio</div>'
verticalAlign: 'bottom'
horizontalAlign: 'center'
stopBy: (coord) ->
@map.addMarker
lat: coord[0]
lng: coord[1]
title: coord[2]
infoWindow:
content: "<p><b>" + coord[2] + "</b></p><p>" + coord[3] + "</p>"
buildPath: ->
path = []
$("img[data-lat]").each (idx, _)->
path.push [
$(this).data('lat'),
$(this).data('lng'),
$(this).data('name'),
$(this).data('descr'),
idx + 1
]
path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment