var marker = new google.maps.Marker({
map: map,
position: point,
icon: 'pointer.png',
title: "test"
});
My map loader perfect, but my marks will not appear.
I do not quite understand why it is happening?
edit 1:
Here is the whole function, I hope it will help answer some of your questions:
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
zoom: 16,
center: new google.maps.LatLng(<?php echo $userRow['latitude']; ?>, <?php echo $userRow['longitude']; ?>),
});
var infoWindow = new google.maps.InfoWindow;
// Change this depending on the name of your PHP or XML file
downloadUrl('http://xxx.esy.es/test/test-marker.php', function(data) {
var xml = data.responseXML;
var markers = xml.documentElement.getElementsByTagName('marker');
Array.prototype.forEach.call(markers, function(markerElem) {
var name = markerElem.getAttribute('username');
var address = markerElem.getAttribute('address');
var point = new google.maps.LatLng(
parseFloat(markerElem.getAttribute('latitude')),
parseFloat(markerElem.getAttribute('longitude')));
var infowincontent = document.createElement('div');
var strong = document.createElement('strong');
strong.textContent = name
infowincontent.appendChild(strong);
infowincontent.appendChild(document.createElement('br'));
var text = document.createElement('text');
text.textContent = address
infowincontent.appendChild(text);
var marker = new google.maps.Marker({
map: map,
position: point,
icon: 'pointer.png',
title: "test"
});
marker.addListener('click', function() {
infoWindow.setContent(infowincontent);
infoWindow.open(map, marker);
});
});
});
}
Edit 2
here it my xml code, it works fine! it is just my marker on the map that do not work
<?php
include_once 'test-dbconnect.php';
function parseToXML($htmlStr)
{
$xmlStr=str_replace('<','<',$htmlStr);
$xmlStr=str_replace('>','>',$xmlStr);
$xmlStr=str_replace('"','"',$xmlStr);
$xmlStr=str_replace("'",''',$xmlStr);
$xmlStr=str_replace("&",'&',$xmlStr);
return $xmlStr;
}
header("Content-type: text/xml");
// Start XML file, echo parent node
echo '<markers>';
$sql = "select * from tbl_users";
$result = mysqli_query($DBcon, $sql) or die("Error in Selecting " . mysqli_error($DBcon));
//create an array
$emparray = array();
while($row =mysqli_fetch_assoc($result))
{
$emparray[] = $row;
echo '<marker ';
echo 'name="' . parseToXML($row['username']) . '" ';
echo 'address="' . parseToXML($row['address']) . '" ';
echo 'lat="' . $row['latitude'] . '" ';
echo 'lng="' . $row['longitude'] . '" ';
echo '/>';
}
//close the db connection
mysqli_close($DBcon);
// End XML file
echo '</markers>';
?>