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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:15:23+00:00 2026-05-16T06:15:23+00:00

I am trying to implement a Maps API V3 and Local Search but I

  • 0

I am trying to implement a Maps API V3 and Local Search but I seem to be having problems. Somehow, the results in the OnLocalSearch() function is empty.

Here is my complete code:

<script type="text/javascript">
//<![CDATA[
$(document).ready(function() {
    // do stuff when DOM is ready
    var geocoder = new google.maps.Geocoder();
    var address = '{{string_location}}';
    var map;

    // Our global state for LocalSearch
    var gInfoWindow;
    var gSelectedResults = [];
    var gCurrentResults = [];
    var gLocalSearch = new GlocalSearch();

    if (geocoder) {
        geocoder.geocode({ 'address': address }, function (results, status) {
            if (status == google.maps.GeocoderStatus.OK) {
                //alert(results[0].geometry.location.lat())
                //alert(results[0].geometry.location.lng())

                //Create the Map and center to geocode results latlong
                var latlng = new google.maps.LatLng(results[0].geometry.location.lat(), results[0].geometry.location.lng());
                var myOptions = {
                    zoom: 14,
                    center: latlng,
                    mapTypeId: google.maps.MapTypeId.ROADMAP
                };

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

                gLocalSearch.setSearchCompleteCallback(this, OnLocalSearch);
                gLocalSearch.execute("{{business_item.name}}");
            } 
            else {
                alert('No results found. Check console.log()');
                console.log("Geocoding address: " + address);
                console.log("Geocoding failed: " + status);
            }
        });
    }

    /*
    Other functions        
    */        
    function OnLocalSearch() {
        if (gLocalSearch.results[0]) { //This is empty. Why?
            var resultLat = gLocalSearch.results[0].lat; 
            var resultLng = gLocalSearch.results[0].lng; 
            var point = new GLatLng(resultLat,resultLng); 
            callbackFunction(point); 
        }else{ 
            alert("not found!"); 
        } 
    }
});
//]]>
</script>

FYI, I am using this as an example and I am stuck for a few hours now about this: http://gmaps-samples-v3.googlecode.com/svn-history/r136/trunk/localsearch/places.html

Any reply will be greatly appreciated.

Regards,
Wenbert

UPDATE
I made a mistake somewhere here:

<script src="http://www.google.com/uds/api?file=uds.js&v=1.0" type="text/javascript"><;/script>
<script src="http://maps.google.com/maps/api/js?v=3.1&sensor=false&region=PH"></script>

Also, make sure you double check the address you are geocoding. I am from the Philippines and it seems that Google only geocodes Major Roads. See http://gmaps-samples.googlecode.com/svn/trunk/mapcoverage_filtered.html

Thanks to jgeerdes from irc.geekshed.net #googleapis

  • 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-16T06:15:24+00:00Added an answer on May 16, 2026 at 6:15 am

    Just making a couple of tweaks so that the code is actually complete, and using an address I know will be geocoded successfully plus a query I know will return something, your code works. Here is what I did:

    <html>
    <head>
     <title>Wenbert test</title>
    <script src="http://www.google.com/jsapi"></script>
     <script type="text/javascript">
    //<![CDATA[
    google.load('jquery','1.4.2');
    google.load('maps','3',{other_params:'sensor=false'});
    google.load('search','1');
    alert('starting...');
    
    $(document).ready(function() {
    alert('here');
        // do stuff when DOM is ready
        var geocoder = new google.maps.Geocoder();
        var address = '4019 lower beaver rd. 50310';
        var map;
    
        // Our global state for LocalSearch
        var gInfoWindow;
        var gSelectedResults = [];
        var gCurrentResults = [];
        var gLocalSearch = new GlocalSearch();
    
        if (geocoder) {
            geocoder.geocode({ 'address': address }, function (results, status) {
                if (status == google.maps.GeocoderStatus.OK) {
                    //alert(results[0].geometry.location.lat())
                    //alert(results[0].geometry.location.lng())
    
                    //Create the Map and center to geocode results latlong
                    var latlng = new google.maps.LatLng(results[0].geometry.location.lat(), results[0].geometry.location.lng());
                    var myOptions = {
                        zoom: 14,
                        center: latlng,
                        mapTypeId: google.maps.MapTypeId.ROADMAP
                    };
    
                    map = new google.maps.Map(document.getElementById("map_canvas"),
                        myOptions);
    
                    gLocalSearch.setSearchCompleteCallback(this, OnLocalSearch);
                    gLocalSearch.execute("debra heights wesleyan church");
                } 
                else {
                    alert('No results found. Check console.log()');
                    console.log("Geocoding address: " + address);
                    console.log("Geocoding failed: " + status);
                }
            });
        }
    
        /*
        Other functions        
        */        
        function OnLocalSearch() {
            if (gLocalSearch.results[0]) { //This is empty. Why?
                var resultLat = gLocalSearch.results[0].lat; 
                var resultLng = gLocalSearch.results[0].lng; 
                var point = new google.maps.LatLng(resultLat,resultLng); 
                callbackFunction(point); 
            }else{ 
                alert("not found!"); 
            } 
        }
    });
    //]]>
    </script>
    </head>
    <body>
     <div id="map_canvas" style="height:100%;"></div>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.