<%inherit file="../base.html"/>
<%block name="pagetitle">Waypoints</%block>\

<%block name="moduleConstantsValues">
% if len(waypoints):
module.value('mapFeatureCollection', {
  "type": "FeatureCollection",
  "features": [
    <%
    from json import dumps, loads
    features = [];
    for waypoint in waypoints:
        features.append({
            "type": "Feature",
            "geometry": loads(waypoint['geometry']['geom'])
        })
    features = map(lambda f: dumps(f), features)
    %>
    ${', '.join(features) | n}
  ]
});
% endif
</%block>\

<h1>${self.pagetitle()}</h1>
% if len(waypoints):
  <app-map></app-map>
% endif
<p translate ng-init="nbItems = ${total}">{{nbItems}} waypoints</p>
<ul>
  <li><a href="${request.route_url('waypoints_add')}" translate>Add a waypoint</a></li>
% for waypoint in waypoints:
  <li>
  % for locale in waypoint['locales']:
    <a href="${request.route_url('waypoints_view', id=waypoint['document_id'], culture=locale['culture'])}">${locale['title']}</a> (${locale['culture']})
  % endfor
  - ${waypoint['elevation']} m</li>
% endfor
</ul>

<%inherit file="../base.html"/>
<%block name="pagetitle">Waypoints</%block>\

<%block name="moduleConstantsValues">
% if len(waypoints):
module.value('mapFeatureCollection', {
  "type": "FeatureCollection",
  "features": [
    <%
    from json import dumps, loads
    features = [];
    for waypoint in waypoints:
        if waypoint['geometry']['geom'] is not None:
            features.append({
                "type": "Feature",
                "geometry": loads(waypoint['geometry']['geom'])
            })
    features = map(lambda f: dumps(f), features)
    %>
    ${', '.join(features) | n}
  ]
});
% endif
</%block>\

<h1>${self.pagetitle()}</h1>
% if len(waypoints):
  <app-map></app-map>
% endif
<p translate ng-init="nbItems = ${total}">{{nbItems}} waypoints</p>
<ul>
  <li><a href="${request.route_url('waypoints_add')}" translate>Add a waypoint</a></li>
% for waypoint in waypoints:
  <li>
  % for locale in waypoint['locales']:
    <a href="${request.route_url('waypoints_view', id=waypoint['document_id'], culture=locale['culture'])}">${locale['title']}</a> (${locale['culture']})
  % endfor
  - ${waypoint['elevation']} m</li>
% endfor
</ul>

Make sure waypoint has a geometry before adding to the featureCollection
Make sure waypoint has a geometry before adding to the featureCollection
