dra8603 2017-11-22 16:38
浏览 72
已采纳

交互式地图搜索不包含永久链接 - 用JS改变的任何方式?

I've built a site that allows you to search for tattoo parlours in your local area - however, there's no way to save your search. i.e. if you search for London, the url doesn't include London in the search bar, so there's no way for people to share what they've searched with people or for me to use a callback URL to save what the person was searching if they visit another page.

Is there a way to make my map use permalinks specific to what the user is searching for?

Here's the link: Link

  • 写回答

1条回答 默认 最新

  • drdawt9210 2017-11-22 16:57
    关注

    If you're not averse to using a little php, an easy way would be to use PHP form handling on that search bar with something like this:

    <form action="index.php" method="post">
    

    That way you could end up using a field like the location to create a URL like:

    http://yoursite.com?location=Ashford
    

    You could check to see if there is post data at all before initializing the map

    <?php
        function se47439788-map(){
            if ($_POST['location']){
                $location = $_POST['location'];
            }
        }
    ?>
    

    Then use the php variable $location in your script.

    <script> var location = <?php echo $location; ?>; </script>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog