0

I am using Google Map v3 Shortcode Plugin

Each post would have its own Google Map already (for ex: [map address="New York, USA" z="15" marker=”yes” ])

I want my users to type in their location (or not) and get direction - which should cause it to create a new Google Map with the direction route.

So I wrote:

 <form class="searchform" action="<?php the_permalink(); ?>" method="post" >
                            <input type="text" value="<?php echo $address; ?>" name="directions_search" class="field s">
                    <input type="submit" value="Get Directions" name="submit" class="submit button"> </form>
    <?php if(isset($_POST['directions_search'])){ 
                $address = htmlspecialchars($_POST['directions_search']); echo do_shortcode('[map address="Queens, New York"  z="15" marker=”yes” start= "'. $address .'" end="New York, USA"]'); } ?>
  1. The new Google Map with direction route doesn't appear - I think because 2 maps cannot exist at the same time. How can I get the new map to appear?

  2. If input is blank, how do I get the Current Location of the user? (for ex: in CityGuide wp theme or in regular Google Map)

Thanks!

4

1 回答 1

0

这是一个非常好的文档,其中包含一个工作示例: http ://code.google.com/intl/en/apis/maps/documentation/javascript/directions.html#DirectionsRequests

我想您需要一个 Javascript 将(事件:提交)挂钩到您的表单(如 jQuery)并执行地图请求。

于 2012-03-09T08:47:43.417 回答