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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:12:08+00:00 2026-06-07T11:12:08+00:00

This question is solved, even though the answer is irrelevant to the title. This

  • 0

This question is solved, even though the answer is irrelevant to the title. This was a badly structured question and to my disappointment I can’t delete it as it is. Thanks for the help and looking at the code.

I have 2 normal javascripts function and one jquery function for my application using google maps. In brief, it looks like this

<script type="text/javascript">
window.onload = function()
{
    initialize();
}
</script>

<script type="text/javascript">
var geocoder;
var markerE;
var theLocation;
var myLatlng;
var infowindow = new google.maps.InfoWindow();
var markersArray = [];
var eventMarkerArr = [];
var retrievedLatLng;
var retrievedLatLngArr = [];

var map;
$(document).ready(function(){    
 $('#tabs a').click(function(e){
    e.preventDefault();
    $(this).tab('show');
    if($(this).attr("href").substring(1)=='event')
    {   
        show('event');
        hide('location');
    }
    else if($(this).attr("href").substring(1)=='location')
    {
        show('location');
        hide('event');
    }
    });
   });


    function initialize() {
 geocoder = new google.maps.Geocoder(); 
 var myLatlng = new google.maps.LatLng(1.3667, 103.7500);
  var myOptions = {
    zoom: 13,
    center: myLatlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
     styles:[{
         featureType: "poi.attraction",
            stylers: [
              { visibility: "off" }
                ]},{
                featureType: "poi.business",
                stylers: [
                  { visibility: "off" }
                ]
              },{
                featureType: "poi.government",
                stylers: [
                  { visibility: "off" }
                ]
              },{
                featureType: "poi.medical",
                stylers: [
                  { visibility: "off" }
                ]
              },{
                featureType: "poi.park",
                stylers: [
                  { visibility: "off" }
                ]
              },{
                featureType: "poi.place_of_worship",
                stylers: [
                  { visibility: "off" }
                ]
              },{
                featureType: "poi.school",
                stylers: [
                  { visibility: "off" }
                ]
              },{
                featureType: "poi.sports_complex",
                stylers: [
                  { visibility: "off" }
                ]
              },{
              }
            ]
    };

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

  if (postalArr) {
        for (var i = 0; i < postalArr.length; i++ ) {
            codeAddress(postalArr[i]);
        }
  }
  else
  {
      document.getElementById("event_list").value = "There are no events!";
  }

  var locationPin = 'images/green-pin.png'; 


}     

var address;
var eventPin = "images/blue-pin.png";
function codeAddress(postal) {      
    geocoder.geocode( {'address': postal + ", Singapore"}, function(results, status) {
      if (status == google.maps.GeocoderStatus.OK) {
        map.setCenter(results[0].geometry.location);
        retrievedLatLng = results[0].geometry.location;
        var eventwindow = new google.maps.InfoWindow();
        var markerE = new google.maps.Marker({
            map: map,
            position: results[0].geometry.location,
            icon: eventPin,
        });
        markerE.mycategory = "event";
        markerE.setVisible(false);
        google.maps.event.addListener(markerE, 'click', function(){
            eventwindow = new google.maps.InfoWindow({
                content: "hello",
            });
            eventwindow.open(map,marker);
        });
        $.ajax({
          type:"GET",
          url: "http://maps.googleapis.com/maps/api/geocode/json?latlng="+retrievedLatLng+"&sensor=false",
          dataType: "jsonp",
          success: function(json){
          if(json.status == 'OK')
            {
            alert("success");
            }
    }
});
        eventMarkerArr.push(markerE);
        retrievedLatLngArr.push("codeAddress:"+retrievedLatLng);
        alert(retrievedLatLngArr[0]);
      } else {
        alert("Geocode was not successful for the following reason: " + status);
      }
    });
  }

google.maps.event.addDomListener(window, ‘load’, initialize);

The reason why I’m doing this is because I can’t seem to get latlng. What i did at first was to initialize the maps with window.onload = function(){ initialize() } and call the .ajax function in a $(window).load(function(){...}); I can’t get it right either ways.

Sorry if this sounds confusing. I’ll add in more details if this isn’t enough.

Edit:

results[0].geometry.location is the latitude longtitude that is produced from reverse geocoding a 6 digit postal code. I want the full address, but only have the 6 digit postal code. The latitude and longtitude is used to also place a marker on the google map. So to get the full address I’m trying to get a json result using the url provided by google.

More Edit:
Added full length of code

  • 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-07T11:12:10+00:00Added an answer on June 7, 2026 at 11:12 am

    ASSUMING that results[0].geometry.location is ALREADY a valid location. I do not see this to be a fact, but you might have that already

      url: "http://maps.googleapis.com/maps/api/geocode/json?latlng="+results[0].geometry.location.lat() +","+results[0].geometry.location.leg()+"&sensor=false";
    

    You might want to check if the seperation with comma is correct

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

Sidebar

Related Questions

I understand the problem that OSGI solved thanks to this question.... What does OSGi
I asked this question and got an excellent answer (thanks!). Part of the problem
edit This question is solved! Having something weird. I'm using html { font-size: 100%
I have asked this question before and the problem was half solved in the
This is an Amazon interview Question.I have solved this problem in O(n) using dynamic
This is not really a question because I just solved the problem, but I
My question is not about how to solve this error(I already solved it) but
Sorry for this simple question, but I can't solve it... There is an example:
I haven`t found answer to my question using search, though I thought it is
This is not exactly a straight-out question because I have just solved it, but

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.