The map markers are nowhere to be found on the map when using Internet Explorer

Take a look at this code I wrote...

var styles = [
  {
    "featureType": "landscape",
    "stylers": [
      {"weight": 0.1},
      {"color": "#E7EDEF"}
    ]
  },
  ...
  {
    "featureType": "poi.park",
    "elementType": "labels",
    "stylers": [
      {"visibility": "on"}
    ]
  }
];

var map;
function initialize() {
  var centerM = new google.maps.LatLng(42.641185, 14.015790);
  var iconBase = window.location.origin + Drupal.settings.basePath + 'sites/default/themes/actomedia/img/';

  var mapOptions = {
    zoom: 15,
    center: centerM,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    styles: styles,
    scrollwheel: false
  };        

  map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);

  // Map Marker & infoBox
  markerOpt = {
    map: map,
    icon: iconBase + 'puntoEnergy_map_ico.png',
    title: 'Punto Energy',
    animation: google.maps.Animation.DROP
  };
   markerPicasso = new google.maps.Marker($.extend({position: centerM}, markerOpt));

}
google.maps.event.addDomListener(window, 'load', initialize);

The map displays correctly in Chrome and Firefox, but the marker is not visible in Internet Explorer.
Does anyone know how to solve this issue?

I have tried removing the marker animation and checking for any syntax errors in the code, but the problem persists.

--- UPDATE! ---

In response to Anto Jurković's question, I attempted to print the icon URL and discovered a bug where window.location.origin returns as undefined for me.

To resolve this, I added the following code snippet at the beginning of the JavaScript file (source):

if (!window.location.origin) {
  window.location.origin = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port: '');
}

Answer №1

Below is the function I am using to create a marker:

createMarker(Map, legs[i].start_location, legs[i].start_address, markerletter);

function createMarker(map, latlng, html, color) {       
    var contentString = html;
    var marker = new google.maps.Marker({
        position: latlng,
        map: map,
        shadow: iconShadow,
        icon: getMarkerImage(color),
        shape: iconShape,           
        zIndex: Math.round(latlng.lat() * -100000) << 5
    });

    //marker.myname = label;
    google.maps.event.addListener(marker, 'click', function () {
        //Set Infowindow Logic
    });
    return marker;
}

Javascript

function initialize() {
    var Lattts = document.getElementById('lat').value;
    var Longgs = document.getElementById('long').value;    

    var myLatlng = new google.maps.LatLng(parseFloat(Lattts), parseFloat(Longgs));
    var map_canvas = document.getElementById('map_canvas');
    var map_options = {
        center: myLatlng,
        zoom: 17,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    var map = new google.maps.Map(map_canvas, map_options)

    var icon = {            
        url: 'https://maps.gstatic.com/mapfiles/ms2/micons/blue-dot.png'
    };

    var contentString = 'Contents';

    var infowindow = new google.maps.InfoWindow({
        content: contentString
    });

    var marker = new google.maps.Marker({
        position: myLatlng,
        map: map,
        icon: icon,
        zIndex: Math.round(myLatlng.lat() * -100000) << 5,
        animation: google.maps.Animation.DROP
    });

    //marker.setAnimation(google.maps.Animation.BOUNCE);

    google.maps.event.addListener(marker, 'click', function () {
        infowindow.open(map, marker);
        if (marker.getAnimation() != null) {
            marker.setAnimation(null);
        } else {
            marker.setAnimation(google.maps.Animation.BOUNCE);
        }
    });

        setTimeout(function () { marker.setAnimation(google.maps.Animation.BOUNCE); }, 2000);
    }

    google.maps.event.addDomListener(window, 'load', initialize);

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

Disabling `no-dupe-keys` in ESLint does not seem to be effective

Currently, I am working on a project where I have incorporated Typescript and ESLint. However, I have encountered an issue with the error message stating: An object literal cannot have multiple properties with the same name. I am looking to disable this s ...

Angular event triggered when updating input values from the model

I have developed a custom directive to add functionality to input fields with a specific class. I want to trigger events on blur and focus to update the label style based on Material Design principles. However, when using ng-model in Angular, I also need t ...

Issue with CasperJS: The function this.waitForUrl is not defined and is causing an error

My casperJS script handles form filling, however I encountered the following error message: A TypeError occurred: 'undefined' is not a function (evaluating 'this.waitForUrl') I suspect this might be an issue with using an outdated ver ...

Determine the presence of an image by using a wildcard in the URL

I need to show an image, and if it doesn't exist I want to display a default image. The challenge is that the image can come with any extension. Can someone suggest how I can modify the $.get() function in the code snippet below to make it search for ...

Cobalt does not reflect changes in React components when the component's state is updated

I am currently developing a small React application for Cobalt, and so far everything is running smoothly. However, I have encountered an issue with rerendering a specific portion of HTML when the component's state changes. The layout consists of a me ...

Utilizing jQuery for interacting with iframes

My script functions perfectly on the page, but when I embed it using an iframe, the jQuery features stop working even though the script is written as usual. Even using $.noConflict(); does not resolve the issue. ...

Encountering an error when using JSONP with a period in the callback function

I am currently facing an issue with making an ajax jsonp call. It seems that the json returned contains a dot in the callback function, as shown in the example below: ABCD.render_section({ "page": { "parameters": { "pubDate": "2013-06-05 00:00:00.0", ...

Having trouble with the postcss-import grunt plugin?

Here is the layout of my project: my_project |-- css | -- main.css |-- css-dev | -- main.css |-- node_modules | -- bootstrap | -- dist | -- css | -- bootstrap.css |-- package.json `-- Gruntfile.js The contents of my Gr ...

Using Javascript to map an array with objects from a different array and then returning the computed array

I'm struggling to solve a seemingly simple issue. I have an array that looks like this: Array 1: [ { "id": 1, "date": "2019-03-27", "time": 1, "max_tasks": 3, "reservations": [ 5, 2 ...

Converting Numbers into Words with the power of HTML and JavaScript

CONVERT NUMBER TO WORDS Write a simple JavaScript program that converts a number to words. Include an HTML page where the user can input the number to be converted. The conversion process should involve using both for loops and switch statements. ...

Tips for Saving JSON Response from Fetch API into a JavaScript Object

I am facing an issue trying to store a Fetch API JSON as a JavaScript object in order to use it elsewhere. The console.log test is successful, however I am unable to access the data. The Following Works: It displays console entries with three to-do items: ...

Saving changes to mesh vertices in r67 of Three.js

I've encountered an issue with saving a mesh to a text file after manipulating vertices in my plane model. While the rendering on screen works as expected, the updates are not reflected in the saved file. Interestingly, if I move a vertex before the ...

Tips on resolving JavaScript's failure to adjust to the latest HTML inputs

I'm working on a homepage where users can choose their preferred search engine. The issue I'm facing is that even if they switch between search engines, the result remains the same. I've experimented with if-then statements, but the selecti ...

Failure to successfully transmit data from Ajax to PHP script

When I click on a button in my HTML page, I am trying to retrieve information from my PHP code, but it is not connecting properly. The front page displayed in index.php is as follows: <!DOCTYPE html> <html> <head> <link rel="styleshe ...

Customize the formatting of linked locale messages in Vue's internationalization (i18n) feature using parameters

Is there a way to link locale messages in vue-i18n with a parameter? { "next": "Next step {step+1}: @:steps[{step}]", "steps": [ "Welcome", // 0 "Briefing", // 1 "Finish" // 2 ...

The method piSession.buildPageInteractionSession is not valid

Hey there! I am facing an issue with a simple AJAX call to a PHP file. The request should be sent to the server and return back in an HTML input field. Unfortunately, I have not been able to resolve this error so far. Below is the code snippet: HTML: ...

The Ajax query returned a successful response, yet it unexpectedly triggered an error

Currently, I am delving into the realm of mongodb. I have integrated Express, Body-Parser, and Mongoose into my project, and I'm retrieving data from an online mongodb database hosted on mlab. Everything seems to be functioning smoothly as I've t ...

Currently dealing with a script that utilizes AJAX GET to incorporate JSON data into my table

Greetings and thank you for taking the time to read this! Within my HTML, I have implemented a form element that allows inputting data into 5 different fields. This data is then transmitted to a database using my unique API key. Once stored in the database ...

Python script used to extract data from Vine platform

I am looking to extract post data, such as title, likes, shares, and content, from various brands' public accounts on Vine using Python. Currently, I have a few ideas in mind: There is a Vine API called Vinepy available on GitHub (https://github.c ...

To display a pattern with a series of alternating addition and subtraction operators, starting from -1 and ending at n, use JavaScript to iterate through the numbers and implement the pattern -1+

I've been struggling to locate the values despite numerous attempts. What steps can I take to resolve this issue? Below is my code snippet: var numVal = prompt(""); for (var i = 1; i <= numVal; i++) { if (i % 2 !== 0) { console.log("-"); ...