Multiple markers on map using PHP and XML

294 views
Skip to first unread message

Steve Shacklock

unread,
Feb 9, 2012, 8:26:30 AM2/9/12
to google-map...@googlegroups.com
I'm trying to get a list of properties (that are brought in from an XML file) to be displayed on a map. I've had a search through and nothing has really helped. The problem I'm having is its going through the loop and just returning the last result which is plotted on the map but the other 9 are omitted. Can anyone help me?

<ol class="plist">
<?php foreach($xml_search as $property) { 
if(isset($property->id)) {
?>
<li class="plist1">
        <a href="particulars.php?propertyID=<?php echo $property->id ?>"><?php echo $property->address->street ?>, <?php echo $property->address->town ?></a>
         -
 
<?php if($property->status == "Available"){ ?>
<span class="available"><?php echo $property->status ?></span>
<?php } ?>

<?php if($property->status != "Let Subject to Contract"){ ?>
<?php if($property->status != "Available"){ ?>
<span class="notAvailable"><?php echo $property->status ?></span>
<?php } ?>
<?php } ?>
 
<?php if($property->status == "Let Subject to Contract"){ ?>
<span class="notAvailable">Let STC</span>
<?php } ?>
<br />
        <strong>&pound;<?php echo number_format($property->price); ?> <?php if ($query=="false") { ?> PCM<?php } ?></strong>, <?php echo $property->bedrooms ?> Bed <?php echo $property->type ?> 
    </li>
    <script type="text/javascript">

var myLatlng = new google.maps.LatLng(<?php echo $property->address->latitude ?>,<?php echo $property->address->longitude ?>);
var myOptions = {
 zoom: 10,
 center: new google.maps.LatLng(<?php echo $property->address->latitude; ?>, <?php echo $property->address->longitude; ?>),
 mapTypeId: google.maps.MapTypeId.ROADMAP
}
var marker = new google.maps.Marker({
position: myLatlng,
title:"<?php echo $property->address->advertising ?>",
clickable: true,
icon: 'images/mapicon.png'
});
var map = new google.maps.Map(document.getElementById("map_canvas_1"),
   myOptions);
  
marker.setMap(map);
    </script>
<?php } } //end foreach ?>

</ol>

geoco...@gmail.com

unread,
Feb 9, 2012, 12:21:54 PM2/9/12
to Google Maps JavaScript API v3
On Feb 9, 5:26 am, Steve Shacklock <steve.shackl...@gmail.com> wrote:
> I'm trying to get a list of properties (that are brought in from an XML
> file) to be displayed on a map. I've had a search through and nothing has
> really helped. The problem I'm having is its going through the loop and
> just returning the last result which is plotted on the map but the other 9
> are omitted. Can anyone help me?

Does this help?

http://www.geocodezip.com/v3_MW_example_map3.html

(translated from Mike Williams' v2 tutorial)

-- Larry
Reply all
Reply to author
Forward
0 new messages