Hello. I am having a tough time trying to accomplish something that
seems like it should be relatively simple. I am calling a function
that parses data to XML. One of the attributes is 'username'. I am
using an If...else if....else statement to assign a 'type' attribute.
if username matches the $_SESSION['valid_user'] then type is set to
'me'. the part I am having trouble with is comparing the username to
$_SESSION['friends'] which is a list of 1 or more usernames. If there
is a match I want to set type to 'friend'. Else I want to set type to
'other'. The code works as shown below (sorry, but I cannot load it on
a server) but would like to substitute the commented section with code
that works. Any help is appreciated.
downloadUrl("ReadRows.php", function(data) {
var xml = parseXml(data);
var markers =
xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
var name = markers[i].getAttribute("name");
var address = markers[i].getAttribute("address");
var point = new google.maps.LatLng(
parseFloat(markers[i].getAttribute("lat")),
parseFloat(markers[i].getAttribute("lng")));
var username = markers[i].getAttribute("username");
if (username == "<?php echo $_SESSION['valid_user']?>")
{
type = "me";
}
//else if (username found in $_SESSION['friends'])
//{
// type = "friend";
//}
else
{
type = "other";
};
var html = "<b>" + name + "</b> <br/>" + address +
"<br/>"
+ username;
var icon = customIcons[type] || {};
var marker = new google.maps.Marker({
map: map,
position: point,
icon: icon.icon,
shadow: icon.shadow });
bindInfoWindow(marker, map, infoWindow, html);
}
});
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-js-api-v3?hl=en.