Skip to content

Instantly share code, notes, and snippets.

@efwe
Created January 7, 2016 16:11
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 efwe/28c03b9c10c15cfda165 to your computer and use it in GitHub Desktop.
Save efwe/28c03b9c10c15cfda165 to your computer and use it in GitHub Desktop.
pointClicked: (point, options, event) ->
if @marker
@map.removeLayer(@marker)
@marker = L.marker(point).addTo(@map)
clickBack = (event) ->
L.DomEvent.stopPropagation(event)
@marker.on('click', clickBack)
callback = (response) =>
if @geoJsonLayer
@map.removeLayer(@geoJsonLayer)
@geoJsonLayer = L.geoJson(response,{
onEachFeature: (feature, layer) =>
@marker.bindPopup('<a href="geo/routes/'+feature.properties.route_id.$oid+'">'+feature.properties.route_title+'</a><br>'+feature.properties.route_start)
})
@map.addLayer(@geoJsonLayer)
$.get '/map/routes/to/' + point[0] + '/' + point[1], callback, 'json'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment