このコードは、alert(markers.length);コメントは解除されます。奇妙なGoogleマップV2マーカーの問題
このjavascriptのアラートが表示されていないときは、マーカーはありません。本当に変です!
function showAddress(address) {
if (geocoder) {//+', '+init_street
geocoder.getLatLng(address,
function(point) {
if (!point) {
document.getElementById("place").value="not found";
//alert(address + " not found");
} else {
// document.getElementById("place").value=point.y.toFixed(4) + "," + point.x.toFixed(4);
map.setCenter(point, 16);
marker.setPoint(point);
//marker.openInfoWindowHtml(address);
}
}
);
}
}
//from a point returns and address!
function showPointAddress(response) {
if (!response || response.Status.code != 200) {//not found
//alert("Status Code:" + response.Status.code);
document.getElementById("place").value="not found";
}
else {//found
map.setCenter(marker.getPoint(), 16);
place = response.Placemark[0];
document.getElementById("place").value=place.address;
//document.getElementById("place").value=marker.getPoint().toUrlValue();
}
}
// Creates a marker at the given point with the given number icon and text
function createMarker(p,text) {
var marker = new GMarker(p);
if (text!=""){
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(text);});
}
return marker;
}
` var geocoder = null;`
` var map = null;`
function load() {//loading the map
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map"));
map.enableScrollWheelZoom();
geocoder = new GClientGeocoder();
if (init_street!=""){
geocoder.getLatLng(init_street,function(point) {//set center point in map
if (point){
map.setCenter(point, zoom);
map.addOverlay(createMarker(point,init_street));
map.openInfoWindow(point,init_street);
}
});
}
map.addControl(new GLargeMapControl());
map.setMapType(G_NORMAL_MAP);
}
}`
function(data, responseCode) {
if(responseCode == 200) {
var texts = [];
var addresses = [];
var xml = GXml.parse(data);
var markers = xml.documentElement.getElementsByTagName("item");
alert (markers.length);
for (var i = 0; i < markers.length; i++) {
var address=markers[i].getElementsByTagName('address').item(0).childNodes.item(0).nodeValue;
if (address!=null){
//alert (address);
var title=markers[i].getElementsByTagName('title').item(0).childNodes.item(0).nodeValue;
var link=markers[i].getElementsByTagName('link').item(0).childNodes.item(0).nodeValue;
var desc=markers[i].getElementsByTagName('description').item(0).childNodes.item(0).nodeValue;
desc=desc.substr(0,220);//limit
addresses.push(address);
texts.push("<div style='width: 200px'><a target='_blank' href='" +link+"'>"+title+"</a><br />"+desc+"</div>");
}//if
}//for
for (var i = 0; i < addresses.length; i++) {
geocoder.getLatLng(addresses[i], function (current) {
return function(point) {
if (point) map.addOverlay(createMarker(point,texts[current]));
}
}(i));
}
}//if });
私はマーカーをロードするためにコールバック関数を必要とする問題を理解し、しかし、イム:私は<body onload="load()" onunload="GUnload()">
Previoslly負荷()関数は、関数と呼ばれ、他のされていbodyタグで
迷った。
どんな助けがありましたか? ;)
Thx in advanced !!
これは 'GDownloadUrl'呼び出しの後にあると思います。結果を処理するのを単に遅らせる警告が 'GDownloadUrl'に違いをもたらすような理由は何もわかりません。あなたはリンクを持っていますか(望ましい)?それ以上のコンテキスト(有用ではない)? –
URLはまだありません...そして、はい、GdownloadUrlは次のようになります: 'GDownloadUrl("/rss /?category = <?php echo $ _GET ["category"];?>&type = <?php echo $ _GET [ "タイプ"];>」、 '最初の記事で didntのコピー... この返し:' GDownloadUrl( "?/ RSS /カテゴリ=カサ・農村&タイプ= 1"、 ' 本当に奇妙?。私はちょうど警報を鳴らす必要があり、私のマーカーが表示されます。 –