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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:05:23+00:00 2026-06-07T06:05:23+00:00

I just want to load the Google Maps based on the Mouseover event of

  • 0

I just want to load the Google Maps based on the Mouseover event of different div element. For doing this I just used the following simple code. This code itself not working, can someone tell me what mistake I have made?

<script type="text/javascript">

  function initialize() {
    var mapDiv = document.getElementById('map-canvas');
    var map = new google.maps.Map(mapDiv, {
      center: new google.maps.LatLng(40.740, -74.18),
      zoom: 12,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    });

    var content = '<strong>A info window!</strong><br/>That is bound to a marker';

    var infowindow = new google.maps.InfoWindow({
      content: content
    });

    var marker = new google.maps.Marker({
      map: map,
      position: map.getCenter(),
      draggable: true
    });

    infowindow.open(map, marker);
  }

  google.maps.event.addDomListener($("#showmap"), 'mouseover', function(){ alert("Hi");});
</script>


<div id='showmap'>
  Show Map
</div>
<div id="map-canvas" style="width: 500px; height: 400px"></div>

Above simple alert function itself not called for this simple code.

  • 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-07T06:05:25+00:00Added an answer on June 7, 2026 at 6:05 am

    The selector returns the jQuery object and the needed element can be accessed directly from the element array with a [0] . Also, make it “addDomListenerOnce”, only need to initialize once.

    $("#showmap")[0]
    

    see a demo

    google.maps.event.addDomListenerOnce($("#showmap")[0], 'mouseover', 
                                     function(){ initialize(); });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm relatively new to Android but I just cant google this. I have following
I am working with Google Maps and I want to load the map in
I want to load My ACL plugin to the application, and just start working
I want to detect when the document has just started to load, so that
Just want to know if publishing an application on Google play is allowed using
I just want to ask if anybody has done something like this. Basically, it's
I'm doing some file validation and want to load an UploadedFile into an external
all forms are showing.. I want just that #google-search to be active on page
I just want to read out the google weather api xml with that code
I just want my app to start a browser and load an URL. I

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.