• Hi, thanks for this great plugin. But I am having an issue with custom javascript on the map.

    I have created a textbox on navbar and it takes the parameter and runs this “document.getElementById(“wpsl-search-btn”).click();”

    It lists the stores but map keep showing all stores(it doesn’t focus I guess?). How can I reload map too?

    Below is my javascript to send parameters and click;

    <script type="text/javascript">
    function getParameterByName(name, url) {
        if (!url) {
          url = window.location.href;
        }
        name = name.replace(/[\[\]]/g, "\\$&");
        var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
            results = regex.exec(url);
        if (!results) return null;
        if (!results[2]) return '';
        return decodeURIComponent(results[2].replace(/\+/g, " "));
    }
    
    var foo = getParameterByName('location_box'); 
    
    if (foo != null){
        window.onload=function(){
            document.getElementById('wpsl-search-input').value=foo;
    	document.getElementById("wpsl-search-btn").click();
    	}
    }
    </script>
Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter canyasa

    (@canyasa)

    google.maps.event.trigger(map, ‘resize’);

    doesn’t work, am I doing something wrong? Please help

    Plugin Author Tijmen Smit

    (@tijmensmit)

    google.maps.event.trigger(map, ‘resize’); is not available outside of the wpsl-gmap.min.js, so if you want to use custom code, and want to do things with the map itself, then you have to include the code in the JS file from the store locator itself.

    Not entirely sure what you mean with “It lists the stores but map keep showing all stores(it doesn’t focus I guess?).” If you trigger the submit button, a new search should run that replaces all the results from the previous search.

    Also it’s free plugin, so I can’t really spend to much time debugging custom JS code.

    Thread Starter canyasa

    (@canyasa)

    Thank you for the plugin.

    I added a text field(#location_box) on navbar, it sends the value to #wpsl-search-input and runs .click() function on #wpsl-search-btn , that’s it.

    It brings the correct stores on <div id=”#wpsl-stores”> but map(#wpsl-gmap) keep showing all stores. I couldn’t figure it out why?

    here is the link: https://www.cocosbakery.com

    Plugin Author Tijmen Smit

    (@tijmensmit)

    If you check the browser console, then you will see a few errors, this on being the important one.

    “NetworkError: 404 Not Found – https://www.cocosbakery.com/maps/api/js?language=en&region=us&key=x&#8221;

    Something your site is rewriting the path the Google Maps library. It should be maps.google.com/maps/api/js and not https://www.cocosbakery.com/maps/api/js.

    Thread Starter canyasa

    (@canyasa)

    When I add Browser Key from settings map doesn’t show so I had to add this script to header.php

    <script src=”https://maps.googleapis.com/maps/api/js?key=”+&#8230;..API key…..+”&sensor=false” type=”text/javascript”></script>

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘(“wpsl-search-btn”).click(); map doesn’t focus’ is closed to new replies.