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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:14:24+00:00 2026-06-11T06:14:24+00:00

I was able to put markers on the map, but since I’m using GMap2

  • 0

I was able to put markers on the map, but since I’m using GMap2 I cant put markers on the map anymore. I want to use GMap2 so I can make lat lng out of an address.

<script src="https://maps.googleapis.com/maps/api/js?sensor=true"></script>
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=AIzaSyDrwris-0kRdY16oIQoGc_1qsdOgHbJrXo"
  type="text/javascript"></script>

<script type="text/javascript">
    var map = new GMap2(document.getElementById("chart"));
    map.setUIToDefault();

   navigator.geolocation.getCurrentPosition(function(position) {
   var pos = new google.maps.LatLng(position.coords.latitude,
                                         position.coords.longitude);
   map.setCenter(pos, 14);

   //until now it works fine, but when I add a marker it does nothing

 var marker = new GMarker({
    position: new GLatLng(52.15664,5.40567),
    map: map,
    title: 'NAME'
 });

  • 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-11T06:14:26+00:00Added an answer on June 11, 2026 at 6:14 am

    There are a few issues here.

    Firstly, you’re including two versions of the mapping API, one of which has escaped parameters for some reason. This may be because it was copied from somewhere else. If you require the V2 API, you only need to include that one. Be aware that the API is due to be retired by Google next year.

    Also, your marker instantiation code is incorrect. You should pass the latlng position as the first parameter, then the options as the second in object literal format, e.g.:

    var marker = new GMarker(new GLatLng(<coord>, <coord>), { title:"My Title" });
    

    Finally, you aren’t adding the marker itself to the map. You use the addOverlay method to to this.

    Here’s a worked solution. Press the ‘Add Marker’ button to add a marker in a random position to the map:

    <html>
    <head><title>Map Test</title>
    <script src="http://maps.google.com/maps?file=api&v=2&sensor=true" type="text/javascript"></script>
    
    <script type="text/javascript"> 
    var map;
    function initmap() {
        map = new GMap2(document.getElementById("chart")); 
        map.setUIToDefault(); 
    
        navigator.geolocation.getCurrentPosition(function(position) { 
            var pos = new google.maps.LatLng(position.coords.latitude, 
                                             position.coords.longitude); 
            map.setCenter(pos, 14); 
        });
    }
    
    function AddMarker() {
        var bounds = map.getBounds();
        var southWest = bounds.getSouthWest();
        var northEast = bounds.getNorthEast();
        var lngSpan = northEast.lng() - southWest.lng();
        var latSpan = northEast.lat() - southWest.lat();
        var point = new GLatLng(southWest.lat() + latSpan * Math.random(), 
                                southWest.lng() + lngSpan * Math.random());
        map.addOverlay(new GMarker(point, { title:"My Marker" }));
    }
    
    </script>
    </head>
    <body onload="initmap()">
        <div style="width:300px;height:300px" id="chart"></div>
        <input type="button" onclick="AddMarker();" value="Add Marker"></input>
    </body>
    </html>
    

    Note that the above assumes that geolocation works. In a real world application, you should be testing for errors as illustrated by the API documentation here:

    https://developers.google.com/maps/articles/geolocation

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

Sidebar

Related Questions

I need to put a map on a website but the clients doesn't want
I'd like to be able to put a gtk.ProgressBar in my gtk.Menu, but since
Is it able to put views to the left, but off-screen? I want display
Created a google map with GMap2 and put pinpoints on there that open up
I want to be able to put certain configuration information in my settings.py file
I was able to put together a encryption sample like below but during decryption
I have a list in which i want to be able to put different
I want to be able to put background color in the spaces between the
I want to have a background image and being able to put LabelField ,
I've read about nullif , but haven't been able to put together a SELECT

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.