October 2017
Intermediate to advanced
370 pages
8h 57m
English
In this first approach, we'll set up an amp-form in a server generated page. The page will make a GET submission to itself, and parse the submitted query. Then it will dynamically replace the Google Map URL with the search query. The form will look like this (/ch9/search-map.php):
<form action="search-map.php" method="get" target="_top"> Find location: <input type="text" name="q" placeholder="e.g. Dublin"> <input type="submit" value="search"></form>
We can retrieve the search query with the following code:
<?php $query = isset($_GET['q'])?$_GET['q']:''; ?>
And finally, the amp-iframe that will contain the map:
<amp-iframe height="400" layout="fixed-height" sandbox="allow-scripts allow-same-origin" ...
Read now
Unlock full access