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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:07:43+00:00 2026-06-11T09:07:43+00:00

I am using google maps and google places search, i am having two problems.

  • 0

I am using google maps and google places search, i am having two problems.

1-I want the infowidget to stay open when we move away from a marker. That means all of the info windows will remain open if that marker has been hovered over, right now it closes the previous marker window when another marker’s window opens.

2-I am getting few search results for places. For example when looking for Mcdonalds given a latlng of kansas city, it gives me only one result. The code is here.

function initialize() 
{
    var lat;
    var longitude;
    var zoom;
    var radius_hidden=document.getElementById("hidden_radius").value;
    var searchname=document.getElementById("hidden_searchname").value;
    if(trim(document.getElementById("longitude").value)!="")
    {
        zoom=11; 
        lat=document.getElementById("latitude").value;
        longitude=document.getElementById("longitude").value;
    }
    else
    {
        zoom=11;
        longitude="-88";
        lat="42";
    }
    latlng = new google.maps.LatLng(lat,longitude);
    var myOptions = {
      zoom: zoom,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };

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


    //alert("Radius:"+radius_hidden);
    var requestsearch = {
        location: latlng,

        name: searchname,
        types: ['store'],
        bound:latlngbounds,
        rankBy: google.maps.places.RankBy.DISTANCE
    };
    // keyword: searchname,//name: searchname, to get like pages and name to get exact
    service = new google.maps.places.PlacesService(map);
    //service.textSearch(requestsearch, callback);
    service.search(requestsearch, callback);

    if(map != null) {
        google.maps.event.addListener(map, 'drag', function(event) {
            calculateCenter();  
        });
    }
}
google.maps.event.addDomListener(window, 'load', initialize);


google.maps.event.addDomListener(window, 'resize', function() {
  map.setCenter(center);
  //google.maps.event.trigger(map, 'resize');
});
function calculateCenter() {
    var latlngbounds = new google.maps.LatLngBounds();

for (var i = 0 ; i < markersArray.length ; i++) {
     latlngbounds.extend(markersArray[i].getPosition());
}

//map.setCenter(latlngbounds.getCenter(), map.getBoundsZoomLevel(latlngbounds));
map.setCenter(latlngbounds.getCenter());
map.fitBounds(latlngbounds);
 center = map.getCenter();
}
    function callAfterMarker(){
  alert("Market Clicked");
}
function callback(results, status)
{
    var listing='<table width="100%" border="0">';
    var num=5;
    markersArray = new Array();
    if (status == google.maps.places.PlacesServiceStatus.OK) 
    {
      for (var i = 0; i < results.length; i++) 
      {
        var pincode='';
        var address='';
        geocoder = new google.maps.Geocoder();
        geocoder.geocode({
          'address': results[i].vicinity,
          'partialmatch': true},function(resultsp, status)
          {
            if (status == 'OK' && resultsp.length > 0) 
            {
                address=resultsp[0].formatted_address;
                var len=resultsp[0].address_components.length-1;
                var res=resultsp[0].address_components[len].short_name;
                if(res!=undefined)
                {
                    //address+="<br>Pincode:"+res.toString();
                }
                //listing+='<tr><td>Zip Code: '+res.toString()+'</td></tr>';
            } 
        });

        marker = new google.maps.Marker({
            position: results[i].geometry.location,
            title: results[i].name,
            zIndex: 2,
            icon: gicons["blue"]
        });
        infowindow = new google.maps.InfoWindow();
        google.maps.event.addListener(marker, 'click', (function (marker, i) {
            return function () {
                var contentString = '<div id="infowindow' + i + '"><table width="100%"><tr><td>'+results[i].name+'</td></tr><tr><td style="word-wrap: break-word;">'+getaddress(results[i].vicinity)+'</td></tr><?php if(trim($finalURL)){ echo "<tr><td align=\"center\"><a target=\"_blank\" class=\"sty-action-buttn\" href=\"".$finalURL."\">".trim(getFieldFromDB('user_config','BubbleText'))."</a></td></tr>"; }else if(trim(getFieldFromDB('user_config','ActionLink'))){ echo "<tr><td align=\"center\"><a target=\"_blank\" class=\"sty-action-buttn\" href=\"".trim(getFieldFromDB('user_config','ActionLink'))."\">".trim(getFieldFromDB('user_config','BubbleText'))."</a></td></tr>"; }?></table></div>';
                infowindow.setContent(contentString);
                infowindow.open(map, marker);
            }
        })(marker, i));

        google.maps.event.addListener(marker, 'mouseover', (function (marker, i) {
            return function () {
            var contentString = '<div id="infowindow' + i + '"><table width="100%"><tr><td>'+results[i].name+'</td></tr><tr><td style="word-wrap: break-word;">'+getaddress(results[i].vicinity)+'</td></tr><?php if(trim($finalURL)){ echo "<tr><td align=\"center\"><a target=\"_blank\" class=\"sty-action-buttn\" href=\"".$finalURL."\">".trim(getFieldFromDB('user_config','BubbleText'))."</a></td></tr>"; }else if(trim(getFieldFromDB('user_config','ActionLink'))){ echo "<tr><td align=\"center\"><a target=\"_blank\" class=\"sty-action-buttn\" href=\"".trim(getFieldFromDB('user_config','ActionLink'))."\">".trim(getFieldFromDB('user_config','BubbleText'))."</a></td></tr>"; }?></table></div>';
            var listItem = document.getElementById("item-" + i);
            listItem.className = "grey";
               infowindow.setContent(contentString);
                infowindow.open(map, marker);

            }

        })(marker, i));

              google.maps.event.addListener(marker, 'mouseout', (function (marker, i) {
            return function () {

        /*var contentString = '<div id="infowindow' + i + '"><table width="100%"><tr><td>'+results[i].name+'</td></tr><tr><td style="word-wrap: break-word;">'+getaddress(results[i].vicinity)+'</td></tr><?php if(trim($finalURL)){ echo "<tr><td align=\"center\"><a target=\"_blank\" class=\"sty-action-buttn\" href=\"".$finalURL."\">".trim(getFieldFromDB('user_config','BubbleText'))."</a></td></tr>"; }else if(trim(getFieldFromDB('user_config','ActionLink'))){ echo "<tr><td align=\"center\"><a target=\"_blank\" class=\"sty-action-buttn\" href=\"".trim(getFieldFromDB('user_config','ActionLink'))."\">".trim(getFieldFromDB('user_config','BubbleText'))."</a></td></tr>"; }?></table></div>';*/
            var listItem = document.getElementById("item-" + i);
            listItem.className = "change";
             marker.setIcon(gicons["blue"]);
             /* infowindow.setContent(contentString);
                infowindow.open(map, marker);*/

            }

        })(marker, i));

        markersArray.push(marker);
        calculateCenter();
        listing+='<tr><td>';

        var address_link=results[i].vicinity.replace(" ","+");
        if(i==0)
        {
            listing+='<table id="div5" width="100%" >'; 
        }
        else if(i%5==0)
        {
            num+=5;
            listing+='<table id="div'+num+'" class="myclass" style="display:none;" width="100%">';  
        }
        //'+results[i].name+'
        listing +='<tr id="searchadd"><td ><input type="hidden" value="'+results[i].name+'" name="end'+i+'" id="end'+i+'"></td></tr><tr><td style="word-wrap: break-word;border-bottom:1px solid #cccccc;" onmouseout="markersArray['+i+'].setIcon(gicons.blue)" onmouseover="markersArray['+i+'].setIcon(gicons.yellow);openInfoWindow('+i+')"      class="" id="item-'+i+'">'+getaddress(results[i].vicinity)+'<div id="spacer" style="width:120px;height:1px;float:left;"></div><a   style="width:100px;height: 20px;" class="sty-hyperlink" target="_blank" href="https://maps.google.com/maps?daddr='+address_link+'"><b><?php echo getFieldFromDB('user_config','DirectionText'); ?></b></a><br></td></tr>';

        if(i ==(results.length-1))
        {
            listing+='</table>';
            listing+='<span id="largerwindowlink"><br><a  target="_blank" class="sty-action-buttn" href="http://www.franchiseportals.com/contact.php?id=<?php echo $finalURL; ?>"><?php echo trim(getFieldFromDB('user_config','ActionButtonText')); ?></a></span>';
        }
        else if(i>0 &&(i+1)%5==0)
        {
            listing+='<tr><td align="right"><a class="sty-hyperlink" style="width:100px;height: 20px;" href="javascript:void(0);" onclick="javascript:show_hide_table('+num+');" ><b><?php echo getFieldFromDB('user_config','MoreResultText'); ?></b></a></td></tr></table>';
        }
        listing+='</td></tr>';
      }
      showOverlays(5);
      listing +='</table>';
      if(results.length<=0)
      {
            listing='<br><br><span style="color:green;">Sorry! No stores found.<br>Please try another franchise name</span><br><br>';
      }
    }
    else
    {
        listing='<br><br><span style="color:green;">Sorry! No stores found.<br>Please try another franchise name</span><br><br>';
    }
    document.getElementById("listingAddress").innerHTML=listing;
}
function showOverlays(no) 
{
    if (markersArray) 
    {
        for (i in markersArray) 
        { 
            if(i<no && i>=no-5)
                markersArray[i].setMap(map);
        }
    }
}
function clearOverlays() 
{
    if (markersArray) 
    {
        for (i in markersArray) 
        {
                markersArray[i].setMap(null);
        }
    }
}
function openInfoWindow(loopID)
{
    google.maps.event.trigger(markersArray[(parseInt(loopID))], "click");
}     
function show_hide_table(tablid)
{
    var showid=tablid+5;
    clearOverlays();
    showOverlays(showid);
    if(document.getElementById("div"+showid))
    {
        document.getElementById("div"+showid).style.display="block";
    }
    if(document.getElementById("div"+tablid))
    {
        document.getElementById("div"+tablid).style.display="none"; 
    }
}
function checkPin()
{
    if(document.getElementById("pincode").value=="" || trim(document.getElementById("pincode").value)=="" )
    {
    alert("Please fill the Zip Code");
    document.getElementById("pincode").focus();
    return false;
    }
}
function checkMobPin()
{
    if(document.getElementById("zipcode").value=="" || trim(document.getElementById("zipcode").value)=="Choose other zip code" )
    {
        alert("Please fill the Zip Code");
        document.getElementById("zipcode").focus();
        return false;
    }
    else
    {
        document.getElementById("pincode").value=document.getElementById("zipcode").value;
    }
}
function show_table()
{
    if (document.getElementById("viewOption").value == "list") 
    {
        document.getElementById("maptd").className = "list-map-td-change";
        document.getElementById("addresstd").className="list-address-td-change";
    }
    else
    {
        document.getElementById("maptd").className="list-map-td";
        document.getElementById("addresstd").className="list-address-td";
    }
}
function getaddress(address)
{
    var part=address.split(',');
    var result='';
    for(var i=0; i<part.length; i++)
    {
        result+=part[i]+'<br>'  ;
    }
    return result;
}
//alert($(window).width());
/*$(window).resize(function() {
    if($(window).width()<=600)
        map.setZoom(10);
    if($(window).width()>600)
        map.setZoom(11);
        google.maps.event.trigger(map, 'resize');
});*/

</script>
<script>
$(function() {
    function log( message ) {
        $( "<div/>" ).text( message ).prependTo( "#log" );
        $( "#log" ).attr( "scrollTop", 0 );
    }
        $( "#address" ).autocomplete({              //here you have to write the name of search box, no need to call function from textbox
            source: "jquery4dd/search_content.php",
            minLength: 1,
            selectFirst:true,
            select: function(event, ui) {
                    $('#business_url').val(ui.item.url);
                    $('#address').val(ui.item.value);
               }
        });

});
function checkAddress()
{
  if(document.getElementById("address").value=="" || trim(document.getElementById("address").value)=="Type Name Here" )
  {
    alert("Please fill the Business Name");
    document.getElementById("address").focus();
    return false;
  }
}

EDIT:
You can check result for searching McDonalds here My site . You can also check what paramerters are being passed to query in the url.

  • 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-11T09:07:44+00:00Added an answer on June 11, 2026 at 9:07 am
    1. Actually you have only 1 infoWindow-object for all markers, you need 1 for every single marker.
      replace the mouseover-and-click-part of the callback-function with the following:

      window.zIndex= window.zIndex||100;
      google.maps.event.addListener(marker, 'mouseover', (function (marker, i,infowindow) {
          return function () {
              var contentString = '<div id="infowindow' + i + '"><table width="100%"><tr><td>'+results[i].name+'</td></tr><tr><td style="word-wrap: break-word;">'+getaddress(results[i].vicinity)+'</td></tr><tr><td align="center"><a target="_blank" class="sty-action-buttn" href=" http://www.franchiseopportunities.com/franchisefbo.asp?fboid=">Get More Information</a></td></tr></table></div>';
              infowindow.setContent(contentString);
                   //brings the infoWindow into front
              infowindow.setZIndex(window.zIndex++);
              infowindow.open(map, marker);
          }
      })(marker, i, new google.maps.InfoWindow()));
      
    2. It may be disputed :D, but McDonalds is rather a restaurant than a store, you should change the type to “restaurant”

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

Sidebar

Related Questions

I run a search using google.maps.places.PlacesService(map) and then I place markers on the map
I want to allow users to add places to Google Maps using my app.
I want to pass argument into google places url string. The string is @https://maps.googleapis.com/maps/api/place/search/xml?location=52.577798767,-2.124885567&radius=500&types=bank&sensor=false&key=AIzaSyCcC9pmri9XGOgyhjoHQq37cmcbfhjfghf6bBZe80
I've been using the Google Maps Places API to do search a map for
I'm using Google Maps Javascript API V3 Places Library in order to add Places
I am using geolocation to get the address of places on my google maps
I'm using Google Maps api v. 3 in my website. What I want to
I am using Google Maps JavaScript API v3. I want to wire up to
I am using the Google Maps places API v3 to return a number of
I have a couple of questions regarding using Google maps API, especially the Places

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.