<%  model = "" if local_assigns[:model].blank?
    case model
    when "spent_for"
      startLocations = entries.map{|entry|
      fields = entry.spent_for.try(:spent_type) == 'WkMaterialEntry' ? entry.quantity || '' : entry.hours || ''
      [ entry.spent_for.try(:s_longitude) || '', entry.spent_for.try(:s_latitude) || '', entry.user.name+"\n"+
      entry.project.name+ "\n"+(entry.issue ? entry.issue.subject : "")+"\n"+fields.to_s, "E"
      ]}
      endLocations = entries.map{|entry|
      fields = entry.spent_for.try(:spent_type) == 'WkMaterialEntry' ? entry.quantity || '' : entry.hours || ''
      (entry.spent_for && entry.spent_for.s_longitude == entry.spent_for.e_longitude && entry.spent_for.s_latitude == entry.spent_for.e_latitude) ? ["",""] :
        [ entry.spent_for.try(:e_longitude) || '', entry.spent_for.try(:e_latitude) || '', entry.project.name+ "\n"+(entry.issue ? entry.issue.subject : "")+"\n"+fields.to_s, "S" ]}
      locations = startLocations + endLocations
    when "attendance"
      startLocations = entries.map{ |entry|
        (!entry.id || entry.s_longitude == entry.e_longitude && entry.s_latitude == entry.e_latitude) ? ["",""] : [ entry.s_longitude || "", entry.s_latitude || "", entry.user.name+"\n"+
        l(:label_clock_in)+": "+entry.start_time.localtime.strftime('%R')+"\n"+l(:label_clock_out)+": "+
        (entry.end_time ? entry.end_time.localtime.strftime('%R') : "")+"\n"+l(:field_hours)+": "+entry.hours.to_s, "S" ]
      }
      endLocations = entries.map{ |entry|
        (!entry.id) ? ["",""] : [ entry.e_longitude || "", entry.e_latitude || "", entry.user.name+"\n"+ l(:label_clock_in)+": "+entry.start_time.localtime.strftime('%R')+"\n"+
        l(:label_clock_out)+": "+(entry.end_time ? entry.end_time.localtime.strftime('%R') : "")+"\n"++"\n"+l(:field_hours)+": "+entry.hours.to_s, "E" ]
      }
      locations = startLocations + endLocations
    when "address"
      locations = entries.map{|entry| [ entry.address.try(:longitude) || "", entry.address.try(:latitude) || "" ]}
    when "assets"
      locations = entries.map{|entry|
      (!entry.inventory_item_id) ? ["",""] :
      [ entry.try(:longitude) || "", entry.try(:latitude) || "", l(:label_product)+":"+entry.try(:product_name)+"\n"+l(:field_name)+": "+entry.try(:asset_name)+"\n"+l(:label_rate)+": "+(entry.rate ? entry.try(:rate).to_s : "")+"\n"+ l(:field_location)+": "+(entry.location_name ? entry.try(:location_name) : "")]
      }
    when "activity"
      locations = entries.map{|entry|
      (!entry.id) ? ["",""] : [ entry.try(:longitude) || "", entry.try(:latitude) || "", (entry.assigned_user ? entry.assigned_user.name : "")+"\n"+l(:label_start_date_time)+": "+(entry.start_date ? entry.start_date.localtime.strftime("%Y-%m-%d %H:%M:%S") : "")+"\n"+l(:label_end_date_time)+": "+(entry.end_date ? entry.end_date.localtime.strftime("%Y-%m-%d %H:%M:%S") : "")]}
    end
    locations = [["", ""]] if locations.length == 0
%>
<div id="mapheader" style="width: <%=width%>; height: <%=height%>;float: left;padding-left: 5px;min-height: 600px;">
  <div style="text-align: right;padding-top:5px;">
    <%= link_to_function l(:button_close), '$("#show_on_map").prop("checked", false);$("#query_form").submit()', :class => 'icon fa-close' %>
  </div>
  <div id='mapContainer'style="width: inherit; height: inherit;"></div>
</div>
<%= render partial: "wkgeolocation/location_map", locals: { locations: locations, show_on_map: true } %>
<div style="clear: both;"></div>