Markers in IE not displaying on Google Maps

Hi, I am currently working on a website project that involves integrating Google Maps API with MySQL database to retrieve coordinates. The functionality works perfectly in Chrome and Safari browsers, but unfortunately, the markers do not display in Internet Explorer. Any assistance would be greatly appreciated. I referred to the guide provided by Google here. Below is the code snippet I am using. Thank you for your help.

var customIcons = {
  sport: {
    icon: 'images/markers/sport.png',
  },
  bar: {
    icon: 'images/markers/bar.png',
  },
  poi: {
    icon: 'images/markers/poi.png',
  },
  skola: {
    icon: 'images/markers/skola.png',
  },
  kino: {
    icon: 'images/markers/kino.png',
  },
  divadlo: {
    icon: 'images/markers/divadlo.png',
  }
};

function loadMap() {
  var map = new google.maps.Map(document.getElementById("map"), {
    center: new google.maps.LatLng(49.068299, 17.460907),
    zoom: 15,
    mapTypeId: 'hybrid'
  });
  var infoWindow = new google.maps.InfoWindow;

  // This may need to be adjusted based on the PHP file used
  downloadUrl("querymap.php", function(data) {
    var xml = data.responseXML;
    var markers = xml.documentElement.getElementsByTagName("marker");
    for (var i = 0; i < markers.length; i++) {
      var name = markers[i].getAttribute("name");
      var description = markers[i].getAttribute("description");
      var type = markers[i].getAttribute("type");
      var point = new google.maps.LatLng(
          parseFloat(markers[i].getAttribute("lat")),
          parseFloat(markers[i].getAttribute("lng")));
      var html = "<b>" + name + "</b> <br/>" + description;
      var icon = customIcons[type] || {};
      var marker = new google.maps.Marker({
        map: map,
        position: point,
        animation: google.maps.Animation.DROP,
        icon: icon.icon
      });
      bindInfoWindow(marker, map, infoWindow, html);
    }
  });
}

function bindInfoWindow(marker, map, infoWindow, html) {
  google.maps.event.addListener(marker, 'click', function() {
    infoWindow.setContent(html);
    infoWindow.open(map, marker);
  });
}

function downloadUrl(url, callback) {
  var request = window.ActiveXObject ?
      new ActiveXObject('Microsoft.XMLHTTP') :
      new XMLHttpRequest;

  request.onreadystatechange = function() {
    if (request.readyState == 4) {
      request.onreadystatechange = doNothing;
      callback(request, request.status);
    }
  };

  request.open('GET', url, true);
  request.send(null);
}

function doNothing() {}

Here is the XML output generated by PHP. Could there be an issue with it? Apologies for not providing this earlier.

<?php  

require("dbconfig.php"); 

function parseToXML($htmlStr) 
{ 
$xmlStr=str_replace('<','&lt;',$htmlStr); 
$xmlStr=str_replace('>','&gt;',$xmlStr); 
$xmlStr=str_replace('"','&quot;',$xmlStr); 
$xmlStr=str_replace("'",'&#39;',$xmlStr); 
$xmlStr=str_replace("&",'&amp;',$xmlStr); 
return $xmlStr; 
} 

// Connect to MySQL server
$connection=mysql_connect ($dbserver, $dbuser, $dbpassword);
if (!$connection) {
  die('Connection error : ' . mysql_error());
}

// Select active MySQL database
$db_selected = mysql_select_db($dbname, $connection);
if (!$db_selected) {
  die ('Unable to use db : ' . mysql_error());
}

// Retrieve all rows from the markers table
$query = "SELECT * FROM locations WHERE 1";
$result = mysql_query($query);
if (!$result) {
  die('Query error: ' . mysql_error());
}

header("Content-type: text/xml");

// Start XML file, echo parent node
echo '<markers>';

// Iterate through the rows, printing XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
  // ADD TO XML DOCUMENT NODE
  echo '<marker ';
  echo 'name="' . parseToXML($row['name']) . '" ';
  echo 'description="' . parseToXML($row['description']) . '" ';
  echo 'lat="' . $row['lat'] . '" ';
  echo 'lng="' . $row['lng'] . '" ';
  echo 'type="' . $row['type'] . '" ';
  echo '/>';
}
// End XML file
echo '</markers>';

?>

Answer №1

Extra commas are present in your arrays:

sport: {
     icon: 'images/markers/sport.png',  <-- This is one of the places where extra comma is found
  }

Internet Explorer tends to have issues with these extra commas, whereas other browsers do not encounter any problems. It is recommended to remove them for compatibility.

Answer №2

  game: {icon: 'images/markers/game.png',},

When using Explorer, it's important to include additional commands like latitude or longitude coordinates in your marker setup. Make sure to remove the comma before the closing bracket for proper functionality.

For instance, I've included a sample marker from my project below. Notice how there is no comma after the closing bracket:

var pin = new google.maps.Marker({
    position: new google.maps.LatLng(data.latitude, data.longitude),
    map: map,
    title: location,
    icon: customIcon
});  

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the process for activating focus on an input element within a mat-select component?

How can I activate the cursor on the HTML input element (search field) using a keyboard inside mat-select? It functions properly when using a mouse, but in order to meet WCAG requirements, it needs to be fully functional with keyboard navigation. Click h ...

AngularJS issue with the back button

I've been experiencing some issues with the routing code in my app. app.config(function ($routeProvider) { $routeProvider .when('', { controller:'competitionsContr ...

Ensure that the pop-up text triggered by a button click is contained within the same webpage

Allow me to preface my inquiry by mentioning that I possess very minimal coding knowledge, so please bear with any technical terminology inaccuracies. I currently have a webpage featuring various questions, each accompanied by a button below. Upon clickin ...

Activating the keypress function for the angular boostrap ui typeahead directive

Currently, I am utilizing the angular-ui typeahead directive. My goal is to pre-bind the value of the field (which is simple), and then initiate the type-ahead search function programmatically. However, it appears that there is no direct method to do this. ...

What is the safest method for integrating a private MD5 key into a JavaScript algorithm?

Looking to incorporate online payments into my website using html and jquery. The simplest method seems to be sending a form to a specific link. One of the parameters required is a signature, which is a hash generated from form fields and a private key. Ho ...

Using Ajax to load TYPO3's News extension in version 9.5

I'm exploring the possibility of loading the Details view of a news list via Ajax to improve user experience. Instead of having the entire page reload, I want the old detail to smoothly fade out while the list remains in place on the screen, with just ...

Attaching JavaScript to a dynamically generated anchor element

Currently, I am experimenting with using jquery.qtip on an anchor element within jquery.datatables. The process involves adding a tooltip description to the anchor elements by using tooltip="tooltip desc". In the javascript file, I include the following ...

How is it that the identical group is unable to produce an accurate line chart and its corresponding range chart?

Check out my code snippet on JSFiddle here: https://jsfiddle.net/8yf7j3k6/11/ I am currently working on replicating a similar visualization of my data for a range chart, allowing me to scrub through the chart while utilizing tooltips in the line chart rep ...

Having trouble retrieving the response from Jquery ajax with ajaxoptions

Struggling to utilize jQuery effectively. function fetchData(Id) { var ajaxOptions = { url: 'Api/Client/Get?Id=' + id, type: 'GET', dataType: 'json' }; return $.ajax(ajaxOptions).done().fa ...

Unable to modify variable to play audio

As I work on constructing my website, I am incorporating various sounds to enhance user experience when interacting with buttons and other elements. However, managing multiple audio files has proven challenging, as overlapping sounds often result in no aud ...

Tips for removing cookies with Javascript after an allotted period of time

I need to remove a specific cookie value that I set after a certain time period. For example, I want the cookie to be deleted after 10 seconds. function fullday() { document.getElementById("res").innerHTML="1 day"; document.cookie="day="+1; do ...

Visual Studio Code does not support jumping to the definition

I'm encountering an issue with my node project that utilizes ws. While VSCode recognizes websocket events and functions, it doesn't allow me to jump to the definition of a function added to the prototype. The error message displayed is: No defini ...

Ways to retrieve the identifier of an iframe

document.getElementById(Iframe_id).contentWindow.addEventListener("blur", blurtest, true); This line of code assigns the blur event to an iframe and it is functioning properly. However, when in function blurtest(e) { alert(e.target.id); } An alert ...

Cookies are not being stored in the browser despite the presence of a 'Set-Cookie' header in the response of an AJAX request

Why is the cookie not stored on the browser even if the response contains a 'Set-Cookie' header for an ajax request? Request code: function hitLogin(){ var loginUrl = "http://myapp:8080/login"; var geturl; $.ajax({ ...

What is the reason for receiving a JSX warning even though JSX is not being utilized in the code?

In my Vue.js component file using the Quasar framework, I have the following code block inside the <template>: <q-btn color="green" label="save & continue editing" @click="saveCase()" /> This snippet is par ...

Is it possible to use speech recognition on browsers besides Chrome?

Is there a way to utilize a microphone with JavaScript or HTML5 without relying on Flash technology? I was able to achieve this in Chrome by using webkit-speech, but I am looking for solutions that will work in other browsers as well. Any suggestions wou ...

Tips for ignoring preflight response in AngularJS

When I send a http.post request to my service, I start by sending an Option request as required by Cors. However, I've noticed that the OPTIONS (pre-flight) request does not return any response.data, whereas the POST request does. This creates an iss ...

Is it possible to categorize and order multiple columns simultaneously in SlickGrid?

My question may be simple, but my search results are limited. I turn to the stackoverflow community for help: Can a slickgrid column be grouped while still allowing other columns to be sorted without removing the grouping? For instance, imagine a table wi ...

Verifying a checkbox selection within an Autocomplete feature using MUI

[ { label: 'First', checked: false }, { label: 'Second', checked: true } ] Here is a brief example of how the data may be structured. I am utilizing Material UI's Autocomplete feature to enable searching based on labels. Thes ...

javascript regular expression

Is there a way to extract the text that falls between the first colon and the first period in a string? s:4332Hhj4j32hh432kjh.EF4324rf46543DSVC3443 I attempted using the following regex: /:(.*?)\./g Unfortunately, it still captures the colon and p ...