I'm having a problem and i don't know what i'm doing wrong.Well,
I'm parsing an xml file with php.The if conditiondoesn't work for some reason.
Talking about this line: if (( '<?php echo $item['temp'] ?>' >= "37.0 °C") ) {
I have no idea why this line is not working.
<?php foreach ( $item_array as $item ) : ?>
var latlng = new google.maps.LatLng(parseFloat(<?php echo $item['glat']; ?>),
parseFloat(<?php echo $item['glon']; ?>));
if (( '<?php echo $item['temp'] ?>' >= "37.0 °C") ) {
alert('<?php echo $item['temp']; ?>');
var contentString = '<?php echo $item['title']; ?>' + ' , ' + '<?php echo $item['temp']; ?>' ;
var marker1 = createMarker1( contentString,latlng,hot );
}
var hot = 'weather_icons/hot.png';
function createMarker1( contentString,latlng,hot ) {
var marker1 = new google.maps.Marker({
position: latlng,
map: map,
icon: hot
});
google.maps.event.addListener( marker1, "click", function() {
if (infowindow) infowindow.close();
infowindow = new google.maps.InfoWindow({
content: contentString
});
infowindow.open(map, marker1);
});
return marker1;
}
<?php endforeach; ?>
A sample of the xml file:
<rss version="2.0">
<channel>
<item>
<title>Salonika</title>
<temp>6.7 °C</temp>
<glat>40.422726139672626</glat>
<glon>22.93392777442932</glon>
</item>
</channel>
</rss>
>=operator seems alien to me. Perhaps tryparseInt('<?php echo $item['temp'] ?>', 10) >= '37.0 °C'parseIntwould chop off any fractional portion (parseInt("6.7", 10)is6). Technically as the OP is comparing against a whole number using>=that doesn't matter, butparseFloatstill seems like the more appropriate choice.parseFloatseems more on topic.