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 8621853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:54:41+00:00 2026-06-12T06:54:41+00:00

I am working my way through the Google Maps API and have the following

  • 0

I am working my way through the Google Maps API and have the following thusfar:

var infowindow = null;

$(document).ready(function () { initialize();  });

function initialize() {

    var centerMap = new google.maps.LatLng(39.828175, -98.5795);

    var myOptions = {
        zoom: 4,
        center: centerMap,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    }

    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

    setMarkers(map, sites);
    infowindow = new google.maps.InfoWindow({
            content: "loading..."
        });

    var bikeLayer = new google.maps.BicyclingLayer();
    bikeLayer.setMap(map);
}

var sites = [
    ['Mount Evans', 39.58108, -105.63535, 4, 'This is Mount Evans.'],
    ['Irving Homestead', 40.315939, -105.440630, 2, 'This is the Irving Homestead.'],
    ['Badlands National Park', 43.785890, -101.90175, 1, 'This is Badlands National Park'],
    ['Flatirons in the Spring', 39.99948, -105.28370, 3, 'These are the Flatirons in the spring.']
];



function setMarkers(map, markers) {

    for (var i = 0; i < markers.length; i++) {
        var sites = markers[i];
        var siteLatLng = new google.maps.LatLng(sites[1], sites[2]);
        var marker = new google.maps.Marker({
            position: siteLatLng,
            map: map,
            title: sites[0],
            zIndex: sites[3],
            html: sites[4]
        });

        var contentString = "Some content";

        google.maps.event.addListener(marker, "click", function () {
            //alert(this.html);
            infowindow.setContent(this.html);
            infowindow.open(map, this);
        });
    }
}

I tried to create a Fiddle but it was not showing up.

So, the map supports multiple locations and info boxes, but the part I’m still very confused on is custom info boxes. I did some searching and saw this question/answer, but am having trouble understanding exactly how that works. So, let’s say I have my #map_canvas map and then outside of that, I have an existing #info div (where I would like each info box loaded). So – the styles are not defined in the Google Maps API, it is an existing element that should take over as the info box.

Would anyone be able to nudge me along (or in this case, a shove would be great) to help me better understand how to do this? A quick screen shot of what I’m thinking can be found here. The dark red box on-top of the map is the target.

The custom markers and “active” state (the gold icon for the selected marker) are another challenge as well, but I haven’t given up all hope on those just yet. Any help would be greatly appreciated. Thanks!

  • 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-12T06:54:43+00:00Added an answer on June 12, 2026 at 6:54 am

    Its been a while but this should work.

    When you create your markers, append whatever data you want to append to this marker.

    Here is using the setMarkers function. Glad you added it (Was wondering where you have your loop)

    In the html have your div to take this data like

     <div id="myDivID"></div>
    

    In your js add a reference to it and insert html there

    function setMarkers(map, markers) {
        var myContentDiv = document.getElementById('myDivID');//Reference to you DOM elem  
    
        for (var i = 0; i < markers.length; i++) {
            var sites = markers[i];
            var siteLatLng = new google.maps.LatLng(sites[1], sites[2]);
            var marker = new google.maps.Marker({
                position: siteLatLng,
                map: map,
                title: sites[0],
                zIndex: sites[3],
                html: sites[4]
            });
    
            var contentString = "Some content";
            //marker.xtraData = 'SomeExtraData';//You can even add more data this way
    
            google.maps.event.addListener(marker, "click", function () {
                //alert(this.html);
                var myTemplate = '<h1>'+this.title+'<h1><p>'+this.html+'</p>';
    
                myContentDiv.innerHTML = myTemplate;//Inset this html inside link
                //infowindow.setContent(this.html);
                //infowindow.open(map, this);
            });
        }
    }
    

    Depending on what you are doing you may also want to check out leaflet. Its quite a bit faster than google maps on mobile browsers, and better than ios6 maps hehe.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working my way through some ASP.NET MVC reading and I have a web
TL;DR Is PinView.prototype = _.extend(PinView.prototype, google.maps.OverlayView.prototype) the proper way to have a Backbone View
Greetings, Until now I have mostly been working with google maps v2. I am
I'm new to Google Apps Script. I'm working my way through some simple example
While working my way through the Android tutorials, I came across something I don't
I'm working my way through "Learning jQuery" (Third Edition). In Chapter 4: "Manipulating the
I'm working my way through displaying various data elements from parent & child data,
I'm working my way through Agile Web Development with Rails and am running into
I'm still working my way through some pretty basic Actionscript programming (in Flex), and
I've been working my way through Tim Heuer's Silverlight tuturial , in which you

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.