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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:21:57+00:00 2026-05-31T06:21:57+00:00

How to get elements and change styles by clicking buttons on map control div?

  • 0

How to get elements and change styles by clicking buttons on map control div? I like to have the same effect on map like in buttons in table.

Code: jsFiddle

Update:

With Your help I got expected result: jsFiddle2

  • 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-05-31T06:21:59+00:00Added an answer on May 31, 2026 at 6:21 am

    I’ve updated your gMap.select here, it’s working and hope this is what you want.

    select: function (buttonId){
        gMap.buttons.$line.className="unselected";
        gMap.buttons.$placemark.className="unselected";
        document.getElementById(buttonId).className="selected";
        var divs=window.parent.frames[0].document.getElementsByTagName('div');
        for(i=0;i<divs.length;i++)
        {
            if(divs[i].id.charAt(0)=="c") divs[i].className="unselected";
        }
        var btn='c_'+buttonId;
        window.parent.frames[0].document.getElementById(btn).className="selected";
    }
    

    Update : Here is the updated fiddle. Hope you want this.

    Updates are marked with // Update in the fiddle.

    This is another example of how you can add custom control and it’s event handler in Google map (Using Javascript)

    var map;
    function initialize() {
    map = new google.maps.Map(document.getElementById('map'));
    map.setCenter(new google.maps.LatLng(48.77565,9.181802));
    map.setZoom(12);
    map.setMapTypeId( google.maps.MapTypeId.ROADMAP );
    
    var controlDiv = document.createElement('div');
    var table=document.createElement('TABLE');
    var tbdy=document.createElement('TBODY');
    var tr=document.createElement('TR');
    
    var btn1=document.createElement('input');
    btn1.setAttribute("type", "button");
    btn1.id="c_placemark_b";
    btn1.setAttribute("value", "Button One");
    var td1=document.createElement('TD');
    td1.appendChild(btn1);
    
    var btn2=document.createElement('input');
    btn2.setAttribute("type", "button");
    btn2.id="c_line_b";
    btn2.setAttribute("value", "Button Two");
    var td2=document.createElement('TD');
    td2.appendChild(btn2);
    
    tr.appendChild(td1);
    tr.appendChild(td2);
    tbdy.appendChild(tr);
    table.appendChild(tbdy);
    controlDiv.appendChild(table);
    
    google.maps.event.addDomListener(btn1, 'click', function() {
        //DoSomething
        alert(this.id);
    });
    
    google.maps.event.addDomListener(btn2, 'click', function() {
        //DoSomething
        alert(this.id);
    });
    
    controlDiv.index = 1;
    map.controls[google.maps.ControlPosition.TOP_RIGHT].push(controlDiv);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have some JavaScript code that resizes <div/> elements (adjusts height/width/padding/margin etc.) based on
I'd like to get the HTML elements highlighted as well as the MAKO /
How would be correct to get the font elements in the table with color=#0000cc
My xml looks like this: <nodes><skus><sku>abc</sku><sku>def123</sku></skus></nodes> I want to get all the elements with
The code below assumes that the element we are clicking on is a div.
I wanted to change the styles like color, font size, background, etc of an
I have two elements on the same line floated left and floated right. <style
how can i get elements uniquely from an array
I know how to get elements with a particular attribute : $("#para [attr_all]") But
I'm trying to get the elements in an HTML doc that contain the following

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.