我正在使用Google Map v3 Shortcode Plugin
每个帖子都有自己的谷歌地图(例如:[map address =“New York,USA”z =“15”marker =“yes”])
我希望我的用户输入他们的位置(或不输入)并获得方向 - 这应该会导致它创建一个带有方向路线的新Google地图。
所以我写道:
<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"]'); } ?>
带有方向路线的新Google地图未显示 - 我认为因为2张地图不能同时存在。如何才能显示新地图?
如果输入为空,我如何获取用户的当前位置? (例如:在CityGuide wp主题或常规Google地图中)
谢谢!
答案 0 :(得分:0)
这是一个非常好的文档,有一个工作示例: http://code.google.com/intl/en/apis/maps/documentation/javascript/directions.html#DirectionsRequests
我猜你需要一个Javascript,它将(事件:提交)挂钩到你的表单(比如jQuery)并执行Map请求。