我需要谷歌地图的帮助
我想没有刷新地图更改标记
我从 mysql 获取数据并创建标记
我的文件:
函数初始化(){
var latlng = 新 google.maps.LatLng(55.472627, 23.15918);
var 地理编码器;变量映射;变量标记数组 = []; 变种信息 = [];
var myOptions = { zoom: 8, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP };
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var 编码字符串;var stringArray = [];
encodedString = document.getElementById("encodedString").value; stringArray = encodedString.split(" * *");
变量 x; 对于 (x = 0; x < stringArray.length; x = x + 1){
var addressDetails = [];
addressDetails = stringArray[x].split(",");
var lat = new google.maps.LatLng(addressDetails[0], addressDetails[1]); 控制台.log(纬度);
console.log(addressDetails[0], addressDetails[1]);var marker = new google.maps.Marker({ map: map, position: lat, icon: addressDetails[2], title: "Atnaujinta: "+addressDetails[3]+"" }); } }setInterval('updateMap()', 10000); </script> </head> <?php //get data form mysql mysql_connect('localhost', 'adena_root', 'gintariukas1'); mysql_select_db('adena_nav'); $encodedString = ""; $x = 0; $mysql = mysql_query("SELECT X,Y,marker,data FROM nav"); while ($row = mysql_fetch_array($mysql, MYSQL_NUM)){ if ( $x == 0 ){ $separator = ""; }else{ $separator = "****"; } $encodedString = $encodedString.$separator. "".$row[0]. ",".$row[1]. ",".$row[2]. ",".$row[3]; $x = $x + 1; } ?> <body onload="initialize()"> <input type="hidden" id="encodedString" name="encodedString" value="<?php echo $encodedString; ?>" /> <div id="map_canvas"></div> </body> </html>
也许有人知道?:)