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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:00:54+00:00 2026-06-11T11:00:54+00:00

I have a page that searches a database for stores in an input zipcode,

  • 0

I have a page that searches a database for stores in an input zipcode, maps them as POIs on a google map, and displays the map upon a “show map” click. My problem is that the map seems to be generated only for every other click. I am providing the code that generates botht he table and the map (inside the same ajax call).

To be more specific, the click I am referring to is the trigger for the search function that calls the ajax code – not the “show map” click. In other words, when I search for a zip code the first time, I am able to view a map. The second search yields no map, the third yields a map…and so on…

Any help would be most appreciated

Code is as follows:

function retrieve_stores_in_prox(){
    $('.trigger2').click(function() {   
        $("#map_store").each(function(){
            if ($(this).css("display") == "none")
            {
                $(this).css("display", "block");
            }
            else
            {
                $(this).css("display", "none");
             }
        })
    });
$(document).ready(function() {
    $('#storeList').empty().trigger("update");
    //initialize the store map

    var redicon = new GIcon();
    redicon.image = "images/redCircle.png";
    redicon.iconSize = new GSize(11, 11);
    redicon.iconAnchor = new GPoint(6, 6);
    redicon.infoWindowAnchor = new GPoint(6,6);

    $.ajax({
    type: 'post',
    url: 'trip_planner_store.php',
    dataType: "xml",
    cache: false,
    data: {zip:$("#zip").val()},
    success: function(data) {
        var storemap = new GMap2(document.getElementById("map_store"), { size: new GSize(500,320) });
        storemap.addControl(new GLargeMapControl());
        storemap.addControl(new GMapTypeControl());

        var lat1 = $(data).find('LAT1').text();
        var lon1 = $(data).find('LON1').text();
        storemap.setCenter(new GLatLng(lat1,lon1),8);
        google.maps.event.trigger(storemap, 'resize');

        $(data).find('STORE').each(function(index){
        var lat = parseFloat($(this).find('LATITUDE').text());
        var long = parseFloat($(this).find('LONGITUDE').text());

        var marker = new GMarker(new GLatLng(lat,long), { 
            draggable: false, 
            title: ($(this).find('COMPANY_NAME').text()), 
            icon: redicon,
            disableAutoPan: true,
            supressMapPan: true
        });

        var html = {some stuff for the info window}
                    GEvent.addListener(marker, 'mouseover', function() {
            // When clicked, open an Info Window
                        marker.openInfoWindowHtml(html);

                    });
        storemap.addOverlay(marker);
        //update the store table with the information


           var storeList = {html markup for table};


           //append the current row to the installer table
        $('#storeList').append(storeList);

    });
    $('#storeList').trigger("update");

    }
});
});

}

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

    I have solved the conundrum. The error was actually in my click trigger event being located within the function call. I moved this to the top of my script tag and it now functions as expected. I do not know why having the click event trigger inside the called function only works for every other call. Any guesses would be appreciated.

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

Sidebar

Related Questions

I have an application that searches a database of addresses. The page visitor enters
I have a page that searches a database and generates the following array. I'd
I have a live search on my help page that searches our help database
I currently have an advanced search page that searches a number of fields in
At the minute I have a page with an AJAX script that searches a
So I have a jquery autocomplete on a testbox that searches the database for
I have a rails app. Homepage searches the movies database and displays the results
I have a form that searches a MySQL database using PHP. Currently, when a
So I have this program that searches the SEC Edgar database for annual reports
I have a self-made framework/API and it does some database searches that can take

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.