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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:21:11+00:00 2026-06-07T14:21:11+00:00

How would I add the KML as a layer in google maps (javascript v3)

  • 0

How would I add the KML as a layer in google maps (javascript v3) without changing the map extent/zoom?

I am adding a KML which has several events all over the world, because of this google maps javascript v3 changes the map extent to a very large zoomed out view.

Here is some example code:

function loadOverlay(inc) 
{
    var overlay = new google.maps.KmlLayer(inc);
    overlay.setMap(map);
    overlayArray.push(overlay);
}

function initialize_gmap()
{
    var Rochester = new google.maps.LatLng(43.1561, -77.607); 
    var myOptions = {
    zoom: 11,
    center: Rochester,
    mapTypeId: google.maps.MapTypeId.TERRAIN
    }

    map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}

//Then i initialize the map here, and load the kml
initialize_gmap();
loadOverlay("linktokml.kml");

After the kml is loaded it goes to a very large zoom to show all the locations in the kml.
How would I either prevent this, or go back to my initial extent/zoom?

Thanks in advance.

  • 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-07T14:21:14+00:00Added an answer on June 7, 2026 at 2:21 pm

    Just set preserveViewport option of google.maps.KmlLayerOptions to true:

    var overlay = new google.maps.KmlLayer(inc,{preserveViewport:true});
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a button which when held would add 1 or any
I'm using Google Maps API v3 and am displaying a basic map with about
Has anyone done trimesh refining in the VCG library ? I would add that
We are trying to add dynamic kml to google earth.But we are failing in
I am looking for the Lotus Script which would add X-header to the outgoing
So, I'm relatively new to JavaScript and I was wondering how I would add
I need to create whole-sky maps, but Google Earth in Sky mode has limited
I have this code, which would add one bundle product with the ID of
I'd like to write a gmail extension that would add a button on the
I'm using Elmah with ASP.NET and wondering how I would add custom data, such

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.