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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:38:27+00:00 2026-05-26T13:38:27+00:00

I’m a beginner on Gmaps programming. I want to create an InfoWindow containing two

  • 0

I’m a beginner on Gmaps programming.

I want to create an InfoWindow containing two tabs, one of them just with infomation and the other one with some HTML-form (button and text).

http://gmaps-samples-v3.googlecode.com/svn/trunk/infowindow/tabs.html

var checkText = "Coordinates";

var content = [
  '<div id="tabs">',
  '<ul>',
    '<li><a href="#tab_1"><span>One</span></a></li>',
    '<li><a href="#tab_2"><span>Two</span></a></li>',
  '</ul>',
  '<div id="tab_1">',
     '<p>Marker i:"</p>'+
     '<form id='button'>'+
       '<div>'+
         '<input type='submit' value='Submit' />'+
       '</div>'+
     '</form>',
  '</div>',
  '<div id="tab_2">',
    '<p>Info: '+checkText+'</p>',
  '</div>',
  '</div>'
].join('');

And then, the event listener:

google.maps.event.addListener(infoWindow, 'domready', function() {
  $("#tabs").tabs();
});

google.maps.event.addListener(marker, 'click', function(event) {
  infoWindow.setContent(content);
  infoWindow.open(map, marker);
});

The tabs are perfectly showed and also the button, but I don’t know how to associate it to an action, for example:

marker.draggrable = true;  // letting the marker to move
checkText =  marker.getPosition();  // changing the tab info whenever marker moves

I guess this issue is not related with jquery-tabs but with any infowindow with an html-form inside.
Thanks.

//————————-

I will simplify my question.

I have prepared this example where you can find a “button” in the infowindow:
http://www.sipa.es/prueba_fer/index_prueba.html

How can I associate an action to that button?
For example, changing the zoom, open a new window, etc.

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-05-26T13:38:27+00:00Added an answer on May 26, 2026 at 1:38 pm

    The marker object has drag events:

    • drag: This event is repeatedly fired while the user drags the marker.
    • dragend: This event is fired when the user stops dragging the marker.
    • draggable_changed: This event is fired when the marker’s draggable property changes.
    • dragstart: This event is fired when the user starts dragging the marker.

    Then update your content when the event fires

    google.maps.event.addListener(marker, 'dragend', function(event) {
        checkText = this.getPosition();
        content = [
            '<div id="tabs">',
                    '<ul>',
                        '<li><a href="#tab_1"><span>One</span></a></li>',
                        '<li><a href="#tab_2"><span>Two</span></a></li>',
                    '</ul>',
                '<div id="tab_1">',
                    '<p>Marker i:"</p>'+
                    '<form id="button">'+
                        '<div>'+
                            '<input type="submit" value="Submit" />'+
                        '</div>'+
                    '</form>',
                '</div>',
                    '<div id="tab_2">',
                        '<p>Info: '+checkText+'</p>',
                    '</div>',
            '</div>'
        ].join('');  
    
    });
    

    UPDATE:

    Ok, you need to make sure you catch the elements in the infowindow when they are attached to the DOM. Infowindows have a domready event. I updated the function in your example to show this. Also, remember a postback will reset the map. You did not say whether you need a post back or not, so I cancelled it using e.preventDefault();

    (function () {
         var marker = new google.maps.Marker({
              map: map,
              draggable: false,
              position: new google.maps.LatLng(40.30, -3.71)
         });
         var content = "<div id='tabs'>" +
                       "<form id='button'>" +
                       "<div>" +
                       "<input id='btn' type='submit' value='Submit'/>" +
                       "</div>" +
                       "</form>" +
                       "</div>";
    
         google.maps.event.addListener(marker, 'click', function (event) {
                infoWindow.setContent(content);
                infoWindow.open(map, this);
                map.setCenter(this.getPosition());
    
         });    
    
         google.maps.event.addListener(infoWindow, 'domready', function (e) {
               //attach the click event to the button.
               document.forms.button.btn.onclick = function (e) {
                    e.preventDefault(); //cancels the post back.
                    var currentZoomLevel = map.getZoom();
                    map.setZoom(currentZoomLevel - 2); //zoom out two levels
                };    
         });   
    
    })();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
i want to parse a xhtml file and display in UITableView. what is the
I want to construct a data frame in an Rcpp function, but when I
I'm trying to create an if statement in PHP that prevents a single post

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.