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

The response is dispatched without delay and does not necessitate awaiting

I am facing an issue with waiting for the completion of the getAllData function before proceeding further. let _partnerToken; async function getAllData(dealerId,id){ let partnerToken; var options = { 'method': 'GET', ' ...

The validation for the start and end dates in the datepicker is not functioning properly when

I have integrated a bootstrap date picker into my website. However, I am encountering an issue where the end date validation does not update when I change the start date after the initial selection. <script type="text/javascript" src="htt ...

Transmission of JSON to a C# controller via AJAX results in a Count value of zero in .NET 7

Whenever I attempt to send a JSON object to my controller, the parameter isn't being received. This is the JavaScript code snippet: var input = document.getElementById("input"); input.addEventListener('change', function () { const read ...

The response from a jQuery ajax call to an MVC action method returned empty

I am working on an inventory application with the following layout: <body> <div class="container" style="width: 100%"> <div id="header"> blahblahblah </div> <div class="row"> <div id="rendermenu ...

While the Navbar component functions properly under regular circumstances, it experiences difficulties when used in conjunction with getStaticProps

https://i.stack.imgur.com/zmnYu.pngI have been facing an issue while trying to implement getstaticprops on my page. Whenever I try to include my navbar component, the console throws an error stating that the element type is invalid. Interestingly, I am abl ...

React - The `component` prop you have supplied to ButtonBase is not valid. Please ensure that the children prop is properly displayed within this customized component

I am attempting to use custom SVG icons in place of the default icons from Material UI's Pagination component (V4). However, I keep encountering this console error: Material-UI: The component prop provided to ButtonBase is invalid. Please ensure tha ...

Axios removes the async functionality

Is there a way to achieve the same functionality without using the async function? async EnvioLogin() { const response = await axios.post("api/auth/login", { email: this.email, password: this.password, }); localStorage.setItem(" ...

Exploring the power of Google Charts in conjunction with PHP arrays

I have three PHP arrays with key-value pairs: $needles = ["Needle1", "Needle2", "Needle3", "Needle4", "Needle5"]; $uph1 = ["Needle1" => 3, "Needle3" => 5, "Needle4" => 7]; $uph2 = ["Needle1" => 4, "Needle2" => 2, "Needle3" => 4]; ...

Having trouble retrieving the $scope value in HTML, even though it was assigned within the success function of $http.post

Having trouble accessing the values of $scope properties after a successful $http post in index.html file. Here is the code snippet for reference, any help in resolving this issue would be greatly appreciated as I am new to AngularJs var app = angular.m ...

node.js experiencing crashing following loop iteration

I'm currently developing a performance testing tool using node.js to automate the process and store the results in MySQL. This tool is designed to track the load time of specific web pages in a browser, with the measurement displayed in seconds. I am ...

JavaScript, PHP handlers, and CommentBox all work together seamlessly to create

$("#login").click(function(){ $.getJSON("handlers/Login.php?name="+$("#username").val(), function(data){ console.log(data); //retrieves data from login box and sends it to the handler, returning a JSON array }); template = $("#hid ...

Utilize a fluid AJAX endpoint for the Vue Select2 encapsulated component

I have customized the Wrapper Component Example based on VueJS documentation by adding the AJAX data source feature. You can view my modified code here. My goal is to dynamically set the ajax url property of my select2 component, like this: <select2 :o ...

What is the best way to track and display the window.scrollY value in the console using Next.js

Unfortunately, my ScrollToTop component is not functioning correctly within my app. I have exhausted all possible debugging methods but am still unable to determine why the scrollY value is not being logged as expected. Even after moving the snippet to a ...

I'm struggling to grasp how to effectively utilize a JSON Object in this situation

In my coding project, I am looking to utilize Javascript in order to create a JSON or array that will house pairs of data for 'id' and 'ip'. This way, if I need to retrieve the 'ip' for a specific 'id=123', I can eas ...

Is there a way to customize the animation for a button in material UI?

Trying to implement material UI in React and looking for a button that does not have the standard wave animation effect upon clicking, which you can see demonstrated here. Instead, I am searching for an animation that instantly fills the entire button wit ...

Instructions for transferring a JavaScript array to a Java servlet

Greetings everyone! I am currently working on a web application with an orthodox approach, utilizing AJAX in Java and JavaScript. I am wondering if it is feasible to pass an array from JavaScript to a Servlet. ...

Price Adjuster Tracker

Recently, I coded a small JavaScript program with the purpose of: incrementing or decrementing the quantity of an item by 1 adjusting the price of an item based on the initial price However, my excitement turned to disappointment when I encountered these ...

Chart.js encounters difficulties displaying the chart due to the data in reactjs

My goal is to utilize chartjs-2 to showcase a bar graph with data. Below is the code I've implemented: import React from "react"; import { Bar, Line, Pie } from "react-chartjs-2"; export default class App extends React.Component { constructor(pro ...

Utilizing prerender.io with lazy loading in Angular 2: A comprehensive guide

As Angular Universal is not expected to be included in the CLI for some time, I've had to resort to using prerender.io in order to ensure proper SEO functionality. However, my tests have shown that there are issues with lazy loaded modules causing SEO ...

Explore nested arrays and retrieve objects that have corresponding categories

Working with react+ nextJS and fetching static objects, specifically "posts". The aim is to develop a "related posts" feature for each post that retrieves three posts containing at least one of the categories. Below is an excerpt simplified for clarity: co ...