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

  • Home
  • SEARCH
  • 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 7860407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:16:20+00:00 2026-06-02T22:16:20+00:00

i am using google map.i have a simple example which is working fine.here is

  • 0

i am using google map.i have a simple example which is working fine.here is the code

function initialize() {
        if (GBrowserIsCompatible()) {

var map = new GMap2(document.getElementById('map_canvas'));
            map.setCenter(new GLatLng(1, 103.849), 5);
            map.addOverlay(new ELabel(new GLatLng(1, 103.849), 1, 'style11'));  
            map.addOverlay(new ELabel(new GLatLng(1, 103.980), 2, 'style11'));
            map.setUIToDefault();}}

this above function is working well.Now i want to make it dynamic.like to set center i want to pass variable , like i place of this i will like to use this var center=”1, 103.849″ and i place of this line
map.addOverlay(new ELabel(new GLatLng(1, 103.849), 1, ‘style11’));
i want to use this line in variable….
here is my code which do not work.can anybody correct me?

function initialize() {
        if (GBrowserIsCompatible()) {
            var center = "1, 103.849";
            var Locations = "map.addOverlay(new ELabel(new GLatLng(1, 103.849), 1, 'style11'));map.addOverlay(new ELabel(new GLatLng(1, 103.980), 2, 'style11'));";

            var map = new GMap2(document.getElementById('map_canvas'));
            map.setCenter(new GLatLng(center), 5);
             +Locations +

            map.setUIToDefault();
        }
    }
  • 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-02T22:16:25+00:00Added an answer on June 2, 2026 at 10:16 pm

    GLatLng takes two numbers as arguments, not a string. You need to do

    var centerlat = 1;
    var centerlng = 103.849;
    map.setCenter(new GLatLng(centerlat,centerlng), 5);
    

    I’m not sure what +Locations+ is designed to achieve. It’s a syntax error. Just use the map.addOverlay() line you had before.

    map.addOverlay(new ELabel(new GLatLng(centerlat,centerlng), 2, 'style11'));
    

    Note that Version 2 is deprecated and doesn’t have long to live. Use Version 3 of the API (which is rather different).

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

Sidebar

Related Questions

I have created a simple app which shows a Google Map. I am testing
I have a scenario where I am using Google Map JavaScript API to process
I have a simple POJO mapped to a table using Hibernate. Which works just
I have a Google Map with some simple buttons added to pan to different
I am currently using Google API to point the position on Google map. this
Whenever I place a marker in Google Map using Google API. I want to
I'm displaying a small Google map on a web page using the Google Maps
Is it possible to do a google map lookup using the google maps API
I am using GWT for google map application. I use Google's gwt-maps.jar for mapping
I am dynamically changing the cursor type on a Google Map using the Javascript

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.