如何显示一个标记的更多细节? [英] How can I show more details of one marker?
问题描述
我有:
标记是通过表单提交创建的,表单包含一个邮政编码输入。以下JavaScript将采用此邮政编码,并在google地图上显示为标记。 (这是一个不同的页面)
What I have: The markers was created by a form submission, the form contains a postcode input. The below javascript will take this postcode and display as markers on google map. (this is a different page)
page1.php (代码如下)我有一个php数组,这个数组包含所有的infoWindow数据和javascript是创建地图,标记和inforwindows。
page1.php (code below)I have a php array, this array contains all infoWindow data and the javascript is to create map, markers and inforwindows.
<?php
..............
$info= array();
foreach($details as $d) {
$info[] = "<div id='infoData'>".$d['name'].$d['quantity']."<button id='details' onclick='window.location.href= \\\"page2.php\\\"'>Detail</button>"."<div>";
}
//.........
?>
上面的代码是infoWindow上的所有内容。点击该产品阵列中的该按钮将转到page2.php
The above code is everything on the infoWindow. Click that button in the products array will going to page2.php
<script>
//...................
function init() {
var mapDiv = document.getElementById("map");
var mapOptions = {
center: new google.maps.LatLng(51.528308,-0.3817765),
zoom: 12,
mapTypeId: 'roadmap'
};
var map = new google.maps.Map(mapDiv, mapOptions);
///////////////add markers//////////
var addressArray = ("abc", "def","xxx"), infoArray = (<?php echo $i; ?>);
var geocoder = new google.maps.Geocoder();
for (var i = 0, j=addressArray.length; i < j; i++) {
var info = infoArray[i];
geocoder.geocode({'address': addressArray[i]}, createCallback(info, map));
} //callback function
}
function createCallback(info, map) {
var callback = function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location,
title: 'Click for more details'
});
//..................
</script>
我想要实现什么:
page2.php
我想在 infowindow $ c $中显示
page1.php
按钮的更多细节c>我刚点击了我该怎么办?任何提示??
What I want to achieve:
page2.php
I want to show more details of that page1.php
button in infowindow
I just clicked. How should I do this? Any hint??
我在第二页写了PHP代码,但是我只是把所有的记录都记录下来,
那个标记只是点击了和page2之间没有关联记录。我该如何实现?第二页不包含任何地图,只是纯文本数据。
I wrote php code on page two, but I just getting all records out, there's no associations between that marker just clicked and the page2 record. How can I achieve this? page two do not contain any map, just purely text data.
推荐答案
在你的代码中,你可以传递一个唯一的密钥或id您要在page2.php上显示该记录,并使用 $ _ GET
方法获取该ID,并用于显示该标记的详细信息。
In your code you can pass a unique key or id of that record you want to show on page2.php and get that id using $_GET
method and use to show details of that marker.
on page1.php
on page1.php
<?php
..............
$info= array();
foreach($details as $d) {
$info[] = "<div id='infoData'>".$d['name'].$d['quantity']."<button id='details' onclick='window.location.href= \\\"page2.php?marker=".$d['id']."\\\"'>Detail</button>"."<div>";
}
//.........
?>
on page2.php
on page2.php
$infomarker = $_GET['marker'];
使用 $ infomarker
获取所有细节。
这篇关于如何显示一个标记的更多细节?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!