Add ajax request for marker investment info
This commit is contained in:
@@ -70,8 +70,17 @@ App.Map =
|
|||||||
$(zoomInputSelector).val ''
|
$(zoomInputSelector).val ''
|
||||||
return
|
return
|
||||||
|
|
||||||
contentPopup = (title,investment,budget) ->
|
openMarkerPopup = (e) ->
|
||||||
content = "<a href='/budgets/#{budget}/investments/#{investment}'>#{title}</a>"
|
marker = e.target
|
||||||
|
|
||||||
|
$.ajax 'investments/' + marker.options['id'] + '/json_data',
|
||||||
|
type: 'GET'
|
||||||
|
dataType: 'json'
|
||||||
|
success: (data) ->
|
||||||
|
e.target.bindPopup(getPopupContent(data)).openPopup()
|
||||||
|
|
||||||
|
getPopupContent = (data) ->
|
||||||
|
content = "<a href='/budgets/#{data['budget_id']}/investments/#{data['investment_id']}'>#{data['investment_title']}</a>"
|
||||||
return content
|
return content
|
||||||
|
|
||||||
mapCenterLatLng = new (L.LatLng)(mapCenterLatitude, mapCenterLongitude)
|
mapCenterLatLng = new (L.LatLng)(mapCenterLatitude, mapCenterLongitude)
|
||||||
@@ -88,8 +97,11 @@ App.Map =
|
|||||||
|
|
||||||
if addMarkerInvestments
|
if addMarkerInvestments
|
||||||
for i in addMarkerInvestments
|
for i in addMarkerInvestments
|
||||||
add_marker=createMarker(i.lat , i.long)
|
if App.Map.validCoordinates(i)
|
||||||
add_marker.bindPopup(contentPopup(i.investment_title, i.investment_id, i.budget_id))
|
marker = createMarker(i.lat, i.long)
|
||||||
|
marker.options['id'] = i.id
|
||||||
|
|
||||||
|
marker.on 'click', openMarkerPopup
|
||||||
|
|
||||||
toogleMap: ->
|
toogleMap: ->
|
||||||
$('.map').toggle()
|
$('.map').toggle()
|
||||||
|
|||||||
Reference in New Issue
Block a user