Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8542979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:11:45+00:00 2026-06-11T12:11:45+00:00

Problem: I’m trying to integrate a slider (carousel) inside an info window of google

  • 0

Problem: I’m trying to integrate a slider (carousel) inside an info window of google map.

1. JQuery code for the slider:

<head>
...
    <script src="js/jquery.anythingslider.js"></script>
    <script>
       // Set up Sliders
        // **************         
        $(function(){
            $('#mySlider').anythingSlider({
                mode                : 'f',   // fade mode - new in v1.8!
                resizeContents      : false, // If true, solitary images/objects in the panel will expand to fit the viewport
                expand              : true,
                navigationSize      : 3,     // Set this to the maximum number of visible navigation tabs; false to disable

                onSlideBegin: function(e,slider) {
                    // keep the current navigation tab in view
                    slider.navWindow( slider.targetPage );
                }
            });
        });
    </script>
  ...
 </head>

2. Html code. This is how would the slider work inside a regular html page:

 <div style="width:450px;height:150px;">        
    <ul id="mySlider">  <!-- id corresponds to id used in Jquery code  -->

       <li>
         Content of Slide 1
       </li>
       <li>
          Content of Slide 2
       </li>
       <li>
          Content of slide 3
       </li>

     </ul>
  </div>

Now, I don’t have much experience with JavaScript so how do I make the jquery code accessible inside an info window. In other words where should I put he slider code?

EDIT:
This is what I tried so far but no luck

(function() {  
// Defining variables that need to be available to some functions
var map, infoWindow;
window.onload = function() {
    // Creating a map
    var options = {
        zoom: 3,
        center: new google.maps.LatLng(37.09, -95.71),
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById('map'), options);
    // Adding a marker to the map
    var marker = new google.maps.Marker({
        position: new google.maps.LatLng(40.756054, -73.986951),
        map: map,
        title: 'Click me'
    });
    google.maps.event.addListener(marker, 'click', function() {


        // add some content to userLi1 
        var userLi1 = '<li>Some awesome content for the 1st list item</li>';

        // add some content userLi2
        var userLi2 = '<li>Some awesome content for the 2nd list item</li>'


        // Check to see if an InfoWindow already exists
        if (!infoWindow) {
            infoWindow = new google.maps.InfoWindow();

        }


        // Setting the content of the InfoWindow to the detail map
        //infoWindow.setContent(detailDiv);

        infoWindow.setContent('<div style = "width:450px;height:150px;"><ul id="mySlider">' + userLi1 + userLi2 + '</ul></div>');

        // Opening the InfoWindow
        infoWindow.open(map, marker);   

    });

    // initiate slider here
    $('#mySlider').anythingSlider({
        mode                : 'f',   // fade mode - new in v1.8!
        resizeContents      : false, // If true, solitary images/objects in the panel will expand to fit the viewport
        expand              : true,
        navigationSize      : 3,     // Set this to the maximum number of visible navigation tabs; false to disable

        onSlideBegin: function(e,slider) {
            // keep the current navigation tab in view
            slider.navWindow( slider.targetPage );
        }
    });
};
})();

When I run the code, the Jquery doesn’t get triggered at all.

EDIT 2: SOLUTION I solved the problem by using McMaster code and wrapping the relevant jquery code with

 google.maps.event.addListener(infowindow, 'domready', function(){
 }); 

So this is the entire code:

 $(document).ready(function() {   // runs jquery when document is ready

function initialize() {
    var mapDiv = document.getElementById('map');
    map = new google.maps.Map(mapDiv, {
        zoom: 3,
        center: new google.maps.LatLng(37.09, -95.71),
        mapTypeId: google.maps.MapTypeId.ROADMAP
    });
    infowindow = new google.maps.InfoWindow({
        content: "holding..."
    });

    // looks for map, when tiles are loaded, fire function addmarkers                 
    google.maps.event.addListenerOnce(map, 'tilesloaded', addMarkers);

}

function addMarkers() {
    var lat =37.09;
    var lng = -95-71;
    var latLng = new google.maps.LatLng(
        lat,
        lng);
    var marker = new google.maps.Marker({
        position: latLng,
        map: map
    });
    // add some content to userLi1
    var userLi1 = '<li>Some awesome content for the 1st list item</li>';

    // add some content userLi2
    var userLi2 = '<li>Some awesome content for the 2nd list item</li>'
    // set marker content
    marker.html = '<div style = "width:450px;height:150px;"><ul id="mySlider">' + userLi1 + userLi2 + '</ul></div>';
    // add listener
    google.maps.event.addListener(marker, 'click', function() {
        infowindow.setContent(marker.html);
        infowindow.open(map, marker);
    });

}

initialize();      
google.maps.event.addListener(infowindow, 'domready', function(){
    // initiate slider here
    $('#mySlider').anythingSlider({
        mode                : 'f',   // fade mode - new in v1.8!
        resizeContents      : false, // If true, solitary images/objects in the panel will expand to fit the viewport
        expand              : true,
        navigationSize      : 3,     // Set this to the maximum number of visible navigation tabs; false to disable

        onSlideBegin: function(e,slider) {
            // keep the current navigation tab in view
            slider.navWindow( slider.targetPage );
        }
    });
}); 


});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T12:11:46+00:00Added an answer on June 11, 2026 at 12:11 pm

    You are actually making a DOM element directly on the document

    you would need to use something like this:

    infoWindow.setContent('<div id="mySlider"><ul><li>' + userLi1 + '</li><li>' + userLi2 + '</li></ul></div>');
    

    EDIT:

    This is fully working script modified from one of my projects to fit your needs:

    $(document).ready(function() {   // runs jquery when document is ready
    
         function initialize() {
                var mapDiv = document.getElementById('map');
                map = new google.maps.Map(mapDiv, {
                     zoom: 3,
                    center: new google.maps.LatLng(37.09, -95.71),
                    mapTypeId: google.maps.MapTypeId.ROADMAP
                });
                infowindow = new google.maps.InfoWindow({
                    content: "holding..."
                });
    
               // looks for map, when tiles are loaded, fire function addmarkers                 
                google.maps.event.addListenerOnce(map, 'tilesloaded', addMarkers);
    
              }
    
              function addMarkers() {
                    var lat =37.09;
                    var lng = -95-71;
                  var latLng = new google.maps.LatLng(
                                                    lat,
                                                    lng);
                  var marker = new google.maps.Marker({
                    position: latLng,
                    map: map
                  });
                 // add some content to userLi1 
                var userLi1 = '<li>Some awesome content for the 1st list item</li>';
    
                // add some content userLi2
                var userLi2 = '<li>Some awesome content for the 2nd list item</li>'
                  // set marker content
                  marker.html = '<div style = "width:450px;height:150px;"><ul id="slider2">' + userLi1 + userLi2 + '</ul></div>';
                 // add listener 
                 google.maps.event.addListener(marker, 'click', function() {
                        infowindow.setContent(marker.html);
                      infowindow.open(map, marker);
                    });
    
              }
    
              initialize();      
              // initiate slider here
            $('#mySlider').anythingSlider({
                mode                : 'f',   // fade mode - new in v1.8!
                resizeContents      : false, // If true, solitary images/objects in the panel will expand to fit the viewport
                expand              : true,
                navigationSize      : 3,     // Set this to the maximum number of visible navigation tabs; false to disable
    
                onSlideBegin: function(e,slider) {
                    // keep the current navigation tab in view
                    slider.navWindow( slider.targetPage );
                }
            });
    
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem: Been struggling to get my code to load external shaders and it is
Problem in MATLAB Code for solving desired 'n' number of simultaneous equations of the
Problem: I am trying to build a recursive tree using a function and data
PROBLEM: Here's the code: import matplotlib.pyplot as plt plt.bar([1,2],[5,4]) plt.title('this is a very long
Problem: If I pull my app's toolbar off of the window frame and float
Problem: To obtain the id from a radio button using jQuery on click or
Problem I'm currently stuck trying to figure out what iPhone OS Deployment Target setting
Problem: I'm attempting to disable a radio button by using the code below. This
Problem, simple and annoying. Im just trying to print a list of names, collected
PRoblem: i'm trying to create (just for fun) a simple poker card (with a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.