Skip to content

Instantly share code, notes, and snippets.

@drecodeam
Last active December 18, 2018 03:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drecodeam/f30680496bf93c133fbf158bf2caf6e5 to your computer and use it in GitHub Desktop.
Save drecodeam/f30680496bf93c133fbf158bf2caf6e5 to your computer and use it in GitHub Desktop.
# Add a marker for a place
addInfobox = ( coordinates, design_component ) ->
currentPlaceInfobox = design_component.copy()
currentPlaceInfobox.opacity = 0
current_place_name = getPlaceName( coordinates ).then( ( place ) ->
currentPlaceInfobox.subLayersByName('place')[0].text = place.text
)
do ->
infobox = addMarker( coordinates, currentPlaceInfobox )
# Give marker a little vertical offset to make it land on top of the point
infobox.setOffset([0, -50])
originalMarkerSize = design_component.height
# Setting initial height and opacity to zero for animation
infobox.element.height = 0
infobox.element.opacity = 0
infobox.element.animate
height: originalMarkerSize
opacity: 1
options:
time: 1
curve: Spring
return infobox
# Let's call the function we created once we click on the marker
initialMarker.element.on Events.Click, ->
# Get the current marker's coordinates
coordinates = initialMarker.getLngLat()
currentCoordinates = [coordinates.lat, coordinates.lng]
# Create the infobox
infobox = addInfobox( currentCoordinates, place_infobox )
# Change index of the infobox to be on the top
infobox.element.index = 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment