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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:17:01+00:00 2026-05-28T02:17:01+00:00

I have an html page with google maps in one of the divs called

  • 0

I have an html page with google maps in one of the divs called map.

  var map = new google.maps.Map(document.getElementById('map'),mapOptions);

Now I want to have the same google maps in multiple webpages. How do I reference this div in other pages.

For e.g.

I have another html file like this

<html><head></head>
<body><div><!--How do I get the map here--></div>
</body></html>

Is it posible using Jquery?

—edit—-

So I have a script called myscript.js
which has a

jQuery(document).ready(function(){

which in turn has a

var map = new google.maps.Map(document.getElementById('map'),mapOptions);

So how do I load this script anywhere else?

  • 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-28T02:17:02+00:00Added an answer on May 28, 2026 at 2:17 am

    You won’t reference this div. Map is generated on the fly when page is loaded.

    If you thought about using $('#element').load('map.html #map) – it will stripe all the scripts from loaded content, so generation scripts won’t be available to run.

    Since it’s supposed to be the same map try use jQuery.getScript()?

    // gmaps.js
    function generateMap() {
       //your custom logic
    }
    
    // html file
    <html><head></head>
    <body><div id="gmap"></div>
    <script>
    $.getScript('gmaps.js', function() {
        // Call custom function defined in script
        generateMap();
    });
    
    </script>
    </body></html>
    

    You might also look at examples here on stackoverflow of using jQuery.getScript() and google maps:

    • jquery: how can i load the Google Maps API via ajax?
    • jQuery getScript and Google Maps API Error message

    • http://lostmonocle.com/post/88217865/jquery-getscript-and-the-google-maps-api

    EDIT – updated example

    // map.js
    function generateMap()
    {
        map = new GMap2(document.getElementById("div_map"));
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
        var latLong = new GLatLng(parseFloat(52.2322549), parseFloat(21.0387957));
        var marker = new GMarker(latLong, {draggable : false});
        map.addOverlay(marker);
        map.setCenter(latLong, 15);
    }
    
    
    // map.html - ! CHANGE API KEY !
    <html>
        <head>
            <title>Google Map sample</title>
            <script type="text/javascript" src="js/jquery-1.7.1-min.js"></script>
            <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=PUT_YOUR_KEY_HERE&sensor=false" type="text/javascript"></script>
        </head>
    <body>
    <div id="div_map" style="width:500px;height:400px;background-color:red;"></div>
    <script type="text/javascript">
    $.getScript('map.js', function() {
        generateMap();
    });
    </script>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a map (intanceOf Google Maps) and dinamically i'm appending html to it.
I have 2 javascripts registered to a page. One being for google maps api
I have a page thusly: <html> <head></head> <body> <iframe src=local.html></iframe> <iframe src=http://www.google.com></iframe> </body> </html>
I have an html page called search.html which contains sliders, they work perfectly in
So I'm trying to combine two Google Maps API tutorials into one map. This
I have a GWT web-app with a nearly full page Google map window. Inside
I have noticed that, from Google Maps page, you can get an embed link
Have used google maps dozens of times but cannot get around this one. Doing
I have a full screen Google map with HTML/CSS toolbars overlaid on the map,
I have multiple image maps on one page, and it's a requirement to setup

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.