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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:31:43+00:00 2026-05-28T00:31:43+00:00

Could someone please describes me, where is problem and how the code could be

  • 0

Could someone please describes me, where is problem and how the code could be fixed?

This is not working :

function initialize() {
    var b = new google.maps.LatLng(49.190033, 16.6150523); var Copt = {center:b, map: map, radius: 1000};
    var mapOptions = { zoom: 13, center: b, mapTypeId: google.maps.MapTypeId.ROADMAP }              
    var map = new google.maps.Map(document.getElementById("map_canvas"),mapOptions);
    cir();
    //var C = new google.maps.Circle(Copt);C.setMap(map);
} 

function cir(){    
    var C = new google.maps.Circle(Copt); C.setMap(map);
}

But when I put the content of the function cir() inside initialize, its working:
here

function initialize() {
    var b = new google.maps.LatLng(49.190033, 16.6150523); 
    var Copt = {center:b, map: map, radius: 1000};
    var mapOptions = { zoom: 13, center: b, mapTypeId: google.maps.MapTypeId.ROADMAP }              
    var map = new google.maps.Map(document.getElementById("map_canvas"),mapOptions);
    //cir();
    var C = new google.maps.Circle(Copt);C.setMap(map);
} 

I think, it has something to do with the part <body onload="initialize()">
<div id="map_canvas" style="width:100%; height:100%"></div>
but realy dont understand what to do , how to put a function outside of initialize and how is this working.

Could you please create a short example of function for creating circle and call it from initialize ?

  • 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-28T00:31:43+00:00Added an answer on May 28, 2026 at 12:31 am

    I think the problem you’re having is, your C function doesn’t have the map variable in scope. Try this:

    <!DOCTYPE html>
    <html>
      <head>
        <meta charset="utf-8" />
      </head>
      <body onload="initMap();">
        <div id="map_canvas"></div>
        <script>
            function initMap() {
                var options = {
                    // your options here
                };
                var map = new google.maps.Map(document.getElementById('map_canvas'), options);
                drawCircle(map);
            };
    
            function drawCircle(map) {
                // draw circle logic in here; use map as you would normally
            };
        </script>
      </body>
    </html>
    

    Passing the map parameter to your drawCircle() function means it can then use it. I’m not familiar with the Circle object, but you should be able to implement your code from here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could someone please tell me what is wrong with this code? It works fine
Could someone please help me with this? I need to convert an nchar column
Could someone please help me with the following problem: There are two classes MainForm
Could someone please shed some light on the workings of A-sort (not asort()), which
Could someone please have a look at this: http://jsfiddle.net/tur9b/9/ It's a simple ordered list.
Could someone please provide me with some code or a tuorial in order to
Could someone please show me a small snippet of code which demonstrates how to
Could someone please help me with this scenario, [Some text] [Some text] Device ID:
Could someone please look at the menu on this webpage: http://www.henryscafebar.co.uk/Home.aspx For some reason
Could someone please explain the below query? ID is not PK and there can

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.