Skip to content

Instantly share code, notes, and snippets.

@fermuch
Created May 18, 2013 15:25
Show Gist options
  • Save fermuch/5604806 to your computer and use it in GitHub Desktop.
Save fermuch/5604806 to your computer and use it in GitHub Desktop.
Gist para el evento de Google I/O Extended - CoffeeScript!
class Map
constructor: (map) ->
mapOptions =
center: new google.maps.LatLng(-29.71371, -57.08556),
zoom: 16,
mapTypeId: google.maps.MapTypeId.ROADMAP
@map = new google.maps.Map map.get(0), mapOptions
@markers = []
addMarker: (lat, lon) ->
geopos = new google.maps.LatLng(lat, lon)
@markers.push new google.maps.Marker
position: geopos,
map: @map
delMarker: (marker) ->
marker.setMap null
getAllMarkers: ->
@markers
$ ->
window.map = new Map $('#map')
for num in [1..10]
rand_num = Math.floor Math.random() * 1000
marker = map.addMarker("-29.71#{rand_num}", "-57.08#{rand_num}")
console.log '--> nuevo marcador!'
setTimeout ->
console.log '--> a punto de eliminar los marcadores'
for marker in map.getAllMarkers()
console.log '--> eliminado marcador!'
map.delMarker marker
, 1000 * 5
<html>
<head>
<title>Google I/O - CoffeeScript</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="javascript.js"></script>
</head>
<body>
<div id="map" style="width:100%; height: 300px;"></div>
</body>
</html>
@fermuch
Copy link
Author

fermuch commented May 18, 2013

Página para instalar: http://nodejs.org/

Comando para ubuntu / debian: sudo apt-get install npm
Comando para Fedora: sudo yum install npm

¿Qué hacer después?
npm install coffee-script

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment