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

时间:2014-05-02 13:33:25

标签: javascript google-maps google-maps-api-3 google-maps-markers markers

我只插入两个items只是为了查看xml的外观。循环显示在每个item image:' 1.gif&# 39;但不在第一项中。在第一项中显示默认标记 任何想法我将如何在第一项中使用图像标记(1.gif)?
这是代码的链接: http://metartestmobile.netau.net/folder6/pirkagia.php
EDITED

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;
                        }
}

xml文件的样本

    <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>

0 个答案:

没有答案