Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 不显示for循环中的第一个标记_Javascript_Google Maps_Google Maps Api 3_Google Maps Markers_Markers - Fatal编程技术网

Javascript 不显示for循环中的第一个标记

Javascript 不显示for循环中的第一个标记,javascript,google-maps,google-maps-api-3,google-maps-markers,markers,Javascript,Google Maps,Google Maps Api 3,Google Maps Markers,Markers,我只插入了两个项目,只是为了查看xml的外观。循环显示在每个项目中图像:“1.gif”,但不显示在第一个项目中。在第一个项目中显示默认标记。 你知道我将如何在第一项中使用图像标记(1.gif)吗? 这里有一个代码链接: 已编辑 给我们这个地图的链接,这样我们就可以看到整个输出。更好的是,如果您可以使用呈现的页面结果创建一个JSFIDLE,我们就可以进行调整并指出改进之处。@Frank Tubor。我刚刚编辑了这个问题。我注意到的第一件事是,你似乎在标记上重叠了lat和long。当我第一次点击其中

我只插入了两个
项目
,只是为了查看
xml
的外观。循环显示在每个
项目
图像
:“1.gif”,但不显示在第一个项目中。在第一个项目中显示默认标记。
你知道我将如何在第一项中使用图像标记(1.gif)吗?
这里有一个代码链接:
已编辑


给我们这个地图的链接,这样我们就可以看到整个输出。更好的是,如果您可以使用呈现的页面结果创建一个JSFIDLE,我们就可以进行调整并指出改进之处。@Frank Tubor。我刚刚编辑了这个问题。我注意到的第一件事是,你似乎在标记上重叠了lat和long。当我第一次点击其中一个时,我在点击另一个“pin”时得到了一个值(三个字母的单词),我得到了一些东西,但是当我点击后退时,它显示了一些不同的东西…我的建议是稍微改变你的lat和long,所以如果有硬重叠,它会移动一个分数lat/long坐标。你的图标直到第一个标记添加到地图后才被定义,所以你会得到第一个标记的默认图标。
var map;
        var infowindow;
            function initialize() {
            var myLatlng = new google.maps.LatLng(38.822590,24.653320);
            var myOptions = {
              zoom: 6,
              center: myLatlng,
              mapTypeId: google.maps.MapTypeId.ROADMAP
            }
            var pirkagia1  = 'pirkagia/1.gif';
            map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
            <?php foreach ( $item_array as $item ) : ?>

                            if ( parseFloat ( '<?php echo $item["fire"] ?>') == 1 ) {
                                var contentString = '<?php echo $item['title']; ?>';                
                                var latlng = new google.maps.LatLng(<?php echo $item['glat'] ?>,<?php echo $item['glon'] ?>);               
                                var marker1 = createMarker1( contentString,latlng,pirkagia1 );
                            }
            <?php endforeach; ?>
            function createMarker1( contentString,latlng,pirkagia1 ) {
                            var marker1 = new google.maps.Marker({
                            position: latlng,
                            map: map,
                            icon: pirkagia1
                            });
                        google.maps.event.addListener( marker1, "click", function() {
                        if (infowindow) infowindow.close();
                            infowindow = new google.maps.InfoWindow({
                            content: contentString
                            });
                            infowindow.open(map, marker1);
                        });
                        return marker1;
                        }
}
    <rss version="2.0">
    <channel>
    <title>
Real time weather in Greece
    </title>
    <link>http://www.123.gr/</link>
    <image>
    <url>
    http://www.123.gr/templates/123/images/123.gif
    </url>
    <title>metar.gr</title>
    <link>http://www.123.gr/</link>
    </image>
    <description>
    Ο καιρός σε πραγματικό χρόνο | Real time weather in Greece | Ενημέρωση Fri, 02 May 2014 15:07:05 +0300
    </description>
    <language>el</language>
    <pubDate>Fri, 02 May 2014 15:07:05 +0300</pubDate>
    <copyright>123.gr</copyright>
    <managingEditor>kondilis@123.gr</managingEditor>
    <webMaster>admin@123.gr</webMaster>
    <item>
    <title>Alexan</title>
    <fire>1</fire>
    <glat>39.659859</glat>
    <glon>20.857415</glon>
    </item>
    <item>
    <title>Nea Medounia</title>
    <fire>1</fire>
    <glat>40.24360843967902</glat>
    <glon>23.276864290237427</glon>
    </item>
    </channel>