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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:51:05+00:00 2026-06-11T20:51:05+00:00

Possible Duplicate: Google Maps JS API v3 – Simple Multiple Marker Example On my

  • 0

Possible Duplicate:
Google Maps JS API v3 – Simple Multiple Marker Example

On my project, you can create markers on the map, and then open a infowindow to put some infos and save then on a database, but when you create a marker, and then another marker, if you click on the first marker it open the infowindow of the second marker.

What can be wrong ? This is my code:
(This is a simplified code, for full code access here)

var marker;
var infoWindow;
function goma()
{
  google.maps.event.addDomListener(teste, 'click', function() 
   {
     doMark = true;     
     doMark2 = false;           
    });
    markNow()

    function markNow(){   

//Marker1
google.maps.event.addListener(map, "click", function(event) 
{

    if (doMark == true && doMark2 == false){


    marker = new google.maps.Marker({
                 position: event.latLng, 
                 map: map, icon: 'Imagens/Oficina.png',
                 shadow: 'Imagens/Oficinasombra.png',
                 draggable : true,
                 animation: google.maps.Animation.DROP});
    google.maps.event.addListener(marker,'click',showWindow);

    doMark = false;
    }

    //Marker2
    else if (doMark2 == true && doMark == false){

   marker = new google.maps.Marker({
                 position: event.latLng, 
                 map: map, icon: 'Imagens/Lojas.png',
                 shadow: 'Imagens/Oficinasombra.png',
                 draggable : true,
                 animation: google.maps.Animation.DROP});
    google.maps.event.addListener(marker,'click',showWindow);


    doMark2 = false;
    }
}
);
var html = "<table>" +
   "<tr><td>Nome:</td> <td><input type='text' id='name'/> </td> </tr>" +
   "<tr><td>Endereco:</td> <td><input type='text' id='address'/></td> </tr>" +
   "<tr><td>Tipo:</td> <td><select id='type'>" +
   "<option value='oficina' SELECTED>oficina</option>" +
   "<option value='restaurante'>restaurante</option>" +
   "</select> </td></tr>" +
   "<tr><td></td><td><input type='button' value='Salvar' onclick='saveData()'/>     </td></tr>";

}

function showWindow(event) 
{
infoWindow.setContent(html); 
infoWindow.open(map,marker); 
} 
  • 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-11T20:51:07+00:00Added an answer on June 11, 2026 at 8:51 pm

    Actually a separate listener should be attached to each marker in your function markNow( )-

     marker = new google.maps.Marker({
                         position: event.latLng, 
                         map: map, icon: 'Imagens/Oficina.png',
                         shadow: 'Imagens/Oficinasombra.png',
                         draggable : true,
                         animation: google.maps.Animation.DROP});
    google.maps.event.addListener(marker,'click',showWindow);
    

    And then-

    function showWindow(event) 
    {
    infoWindow.setContent(html); 
    infoWindow.open(map,marker); 
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Can Google Maps/Places 'autocomplete' API be used via AJAX? There seems to
Possible Duplicate: Looping through Markers with Google Maps API v3 Problem I have a
Possible Duplicate: get all available fonts from google font api How we can retrieve
Possible Duplicate: Android:Google Maps API Key Signup : MD5 certification key I'm tryng to
Possible Duplicate: Reverse Geocoding With Google Map API And PHP To Get Nearest Location
Possible Duplicate: json with google geocoding api json Uncaught SyntaxError: Unexpected token : $.getJSON('http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true&callback=?',
Possible Duplicate: How to detect an android device whether it supports google maps API
Possible Duplicate: Google plus api for posting on wall like facebook I have checked
Possible Duplicate: How can I parse JSON in Google App Engine? json module was
Possible Duplicate: How can I use the Google App engine bulkloader to back up

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.