• websites



This is a sample showing how to implement a seatmap that can be used for theaters, cinemas, airplanes and more. We are showing how to pan & zoom on the seatmap to better select seats, how to keep the availability up to date and how to dynamically select and unselect seats.


Additionally used AMP components must be imported in the header: amp-pan-zoom for making the seatmap zoomable and scrollable

<script async custom-element="amp-pan-zoom" src=""></script>

amp-bind for enabling seat selection

<script async custom-element="amp-bind" src=""></script>

amp-list for showing a list of seats

<script async custom-element="amp-list" src=""></script>

amp-mustache for rendering the amp-list content

<script async custom-template="amp-mustache" src=""></script>

amp-selector for selecting seats on the seatmap

<script async custom-element="amp-selector" src=""></script>

Seatmap state

Here we are using an amp-state called selectedSeats to keep a list of selected seat ids.

<amp-state id="selectedSeats">
  <script type="application/json">

Seatmap implementation

We combine amp-list, amp-bind, amp-pan-zoom and amp-selector to implement a seatmap:

  • amp-list is used to keep the availability of the seatmap up to date.
  • amp-bind is used to update the status of the seats: when a seat is selected we add the seat id to the selectedSeats variable.
  • amp-pan-zoom is used to enable to pan & zoom on mobile devices.
  • amp-selector is used to select seats and style selected seats

Seat map

 <h1>Seat map</h1>
 <div class="seatmap-container">
  <amp-list layout="fill" src="/static/samples/json/seats.json" binding="refresh" items="." single-item noloading>
    <template type="amp-mustache">
      <amp-pan-zoom layout="fill" class="seatmap">
        <amp-selector multiple on="select:AMP.setState({
                  selectedSeats: event.selectedOptions
                })" layout="fill">
          <div class="svg-container">
            <svg preserveAspectRatio="xMidYMin slice" viewBox="0 0 {{width}} {{height}}">
              <rect option="{{id}}" role="button" tabindex="0" class="seat {{unavailable}}" x="{{x}}" y="{{y}}" width="{{width}}" height="{{height}}" rx="{{rx}}" ry="{{ry}}"/>
    <div placeholder>
      <svg class="disabled" viewBox="0 0  " preserveAspectRatio="xMidYMin slice">
자세한 설명이 필요하신가요?

이 페이지의 설명만으로 궁금한 점이 모두 해결되지 않는다면 다른 AMP 사용자에게 문의하여 구체적인 활용 사례를 논의해 보세요.

Stack Overflow로 이동
설명이 부족한 기능을 발견하셨나요?

AMP 프로젝트는 여러분의 참여와 기여를 적극 환영합니다! 오픈 소스 커뮤니티를 통해 지속적으로 활동해 주셔도 좋지만 관심 있는 주제에 한 번만 기여하셔도 큰 도움이 됩니다.

GitHub에서 샘플 수정하기