12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/base/project/app/helpers/localizable_helper.rb', line 12
def add_localizations(locations)
return '' if locations.blank?
js_locations = []
first_location = locations.first
been_img = image_url('map/been.png')
current_img = image_url('map/employee.png')
locations.each do |location|
coordinates = prepare_coordinates(location)
next if coordinates.blank?
if location != first_location
image = been_img
current = true
else
image = current_img
current = false
end
location_id = "loc-#{location.id}"
js_locations << "window.map.addCoordinate({
coordinates: #{coordinates},
icon: '#{image}',
locationId: '#{location_id}',
visited: #{current},
period: true,
properties: { title: '#{location.name}', icon: '#{image}' }
});"
end
js_locations << "window.map.getMap().setCenter(#{prepare_coordinates(first_location)});"
js_locations << 'window.map.getMap().setZoom(15);'
result = js_locations.join("\n")
result.html_safe
end
|