Forum: Premium Settings

This forum is closed for new topics. However, you can still search for a solution in the old topics. For technical support related to the Premium Settings premium extension please open a new premium support ticket.

[Resolved]geocoder working locally, not on server

Forums Premium Settings geocoder working locally, not on server

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #51500

    Hey,

    This is a bit of a strange one.

    I have the following bit of code:

    Which on my local version works fine, but on my server I get ‘Something went wrong while retrieving your location.’.

    The files are exactly the same on both (I just re-uploaded everything to the server to be sure). And the geolocation stuff works from within wordpress admin area, but not with this function call.

    Any ideas why this could be?

    Thanks,
    James

    #51512

    Hi James,
    That is most likely a OVER_QUERY_LIMIT error. That’s when the IP address of your site reaches the geocoding query limit of Google API and the address cannot be geocoded. That is why it happens only on the live site.

    The code you posted above, are you referring to the code from the plugin or a custom script that you added for personal purposes?

    #51549

    Hi Eyal,

    It’s a custom script.

    Here’s the full function (sorry, there’s a lot of debugging stuff in it).

    It’s only geocoding query, so i’m not sure why it would go over a query limit? Is there something I can do about this?

    Basically I have a location entered into a post type, so I want to get that location from the database, and geocode it so I can search by location.

    Thanks your help, this is honestly one of my favourite WordPress plugins and your support is always superb.

    #51569

    You are welcome James.

    It’s only geocoding query, so i’m not sure why it would go over a query limit.

    The query limit is exactly for that – for geocoding. Google API is limited to 2500 geocoding queries per 24 hours per IP address. Now, for mosts sites 2500 queries per 24 hours should be enough. Unless it is a high trafficked site with many queries going on. However, the OVER_QUERY_LIMIT issue is mostly happens on shared hosting. In shared hosting many sites can share the same IP address. And so, if other sites on the same server as yours and use the same IP address as your site are also using Google API, then you will most likely run into the OVER_QUERY_LIMIt issue.

    Is there something I can do about this?

    One thing you can try is contacting your host provider, describe them the issue above and see if there is something that can do about that. I really don’t know if it is possible but you can ask them if they can change the IP address of your site.

    Another option would be to write a script that will use AJAX and client-site ( JavaScript ) geocoder that will geocode the address and save it in database. When using client-site geocoder you are less likely to run into the OVER_QUERY_LIMIT issue.

    I am sorry that I don’t have a solution for you but hopefully the above will help.

    #51570

    BTW, why aren’t you using the function gmw_pt_update_location( $args, $force_refresh = false ) directly which basically does the same as your script above ( unless I am wrong )?

    #51581

    It is shared hosting, maybe it’s to do with that. But if I were to add a post with geo data from the admin panel it works, so i’m not convinced it is that. Surely that would push it over the limit too?

    I did try using gmw_pt_update_location(), which is why it’s commented out in my script. But I got:
    Fatal error: Call to undefined function gmw_pt_update_location()

    Any ideas why I might get that? Do I need to include a gmw script for that to work?

    #51726

    Hi James,

    But if I were to add a post with geo data from the admin panel it works, so i’m not convinced it is that.

    GEO my WP Location section in the admin uses Client-side geocoder, that is why it is working for you. As you can see the geocoding process is done dynamically and not on page load.

    I did try using gmw_pt_update_location(), which is why it’s commented out in my script. But I got:

    That’s because the function is not included by default. You need to include the file “gmw-pt-update-locaiton.php” before running the function.

    #51781

    I’m using the function now, but it’s still working locally but not on my server. I’m not getting any errors, any ideas?

    #51797

    My guess would be the same as before, that your server is hitting the OVER_QUERY_LIMIT of Google API. The function gmw_pt_update_location() uses an HTTP request, which has a 2500 query limit, to geocode an address .
    You will need to write a custom function that will geocode the address using JavaScript instead, in order to overcome the OVER_QUERY_LIMIt issue.

    You can try and verify if the OVER_QUERY_LIMIT is the issue by debugging the geocoder function.

    The function can be found in
    geo-my-wp/includes/geo-my-wp-geocoder.php and if you go to line 41 you should see

    .
    The variable $response is what you need to debug ( var_dump ) and see if the code message says OVER_QUERY_LIMIT.

    #51806

    It’s working this morning, so sounds like the query limit has cleared… I’ll keep an eye on it. It’s not actually going to be live on this server, this is just staging so I might not have the problem on the live server.

    #51813

    Great.
    Yes, if your live site is on a different server than it might work fine.

Viewing 11 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic.