Google maps V3 search problems - javascript

I have been stuck at this problem for quite a while. I have a database with a little over 100 locations. And I am trying to write a page that will display the closest location to the user. Right now I am using PHP to display the locations in hidden fields and using Javascript to get and display the user location, and to get the distances from the user location(Distance Matrix). The problem I am running into is that I am getting the OVER_QUERY_LIMIT error after about 16 requests. I am getting the error from the distance matrix.

About the OVER_QUERY_LIMIT check the Usage Limits on Distance Matrix API, it sounds to
me you're just going faster than 100 elements per 10 seconds.

Check this Store locator link for better understanding of Finding locations nearby with MySQL
http://code.google.com/apis/maps/articles/phpsqlsearch.html

Related

How to verify the distance between 2 canadian zip code

I would like to know what is the best way to get the distance between 2 (zip code) or postal code in Canada. I have seen post about MySQL doing so with US zip code.
Or I guess that I could probably translate a zip code to coordinates and then triangulate distances? If anyone can share tips on this I would apreciate!
Im working with Angular JS and Node JS but I could do with PHP as well.
An Api should be free and be able to handle large ammount of querys.
Thank You
Google Maps API can do it, by setting origin and destination on the distancematrix API.
https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&origins=M4C4Y7&destinations=H1A0A2

Homepage Ajax/Google Maps - Server overhead

Adding a Google Map plugin to our homepage, which updates a single marker dynamically whenever there is a new product search on our site (which we read from our database). So, "has there been a new search via our site? If yes, reposition the marker based on the new search's coords".
Currently every "n" seconds (haven't settled on a seconds value yet) an Ajax call is made (using SetInterval) to determine if there has been a new search, and if there has it returns a small JSON response. The script run via the Ajax call is a PHP script, which queries the database for the last row in our searches table (order by desc limit 1).
So, my question is (not being a sysadmin), could this setup put an undesirable strain on our server? Should i incorporate a timeout session, or something, which turns off the Ajax call after 100 goes, or after 15 mins (i mean, who sits for 15 mins looking at markers dynamically generate on a Google map?!).
Our homepage only receives roughly 200 visits a day.
As you have you given the statistics that your website gets 200 visits per day and that your server is a spitting JSON that you have to extract and display it on the UI, It is a normal practice to have a set up like this one. You can rather ping the server data using AJAX in every 5 sec to get more precise data but it wont cause any performance issue at this level.
Please be sure that you dont have servers that are separated geographically else you have to use some other synchronization mechanism to track users location based on there search.
For AJAX JQuery implementation details please see the following page.
For project implementation as a tutorial please visit this tutorial.

Problems retrieving Fusion Tables data - Google Maps API

I'm developing an JSP application that retrieves a lot of polygons to show on the map.
I will try explain how the application works before tell my problem.
My client needs to check on Google Maps his internal division of territories (a territory is a set of cities, it's a many-to-many association). The territory-city relationship can be changed anytime by loading a file via an application menu. Today we have 35 territories and about 10000 associations territory-city in the system.
I have the polygons with the shape of the cities in Fusion Tables, but when I try to retrieve the shapes, I get the following error:
Code to load the polygons for one territory:
layer = new google.maps.FusionTablesLayer({
query:{
select: 'geometry',
from: {MYKEY},
where: "NAME_CITY IN ("+listOfCities+")"
}
});
Error:
Failed to load resource: the server responded with a status of 414 (Request-URI Too Large)
I'm looking for a way to load these territories from a long time, I already tried to read the KML files from Java, and send the set of coordinates for each city, but the HTML page was like 300MB when done, and it just froze the browser and didn't work. So the Fusion Tables seemed to be the best approach.
I found out a few posts where people were telling to use the POST method to request the data, because of the size of the listOfCities variable(some territories have about 500 cities associated), but they never said how to do it using the Google Maps API.
How can I do that? Anybody have another approach to solve this problem?
Thanks
You must somehow simplify the query. POST is not an option, there is no way to change the method used for the query.
But this could be a point where you can start:
The territory-city relationship can be changed anytime by loading a file via an application menu.
Instead of filtering the cities on your server and query cities, you may add another column to the table, where you store the "relationship", as suggested by geocodezip.
This may be done automatically when "the file" is uploaded(and here you can use POST)
The new where-clause would be simple and short now like e.g.: territory=35

Google Maps API v3 are not displaying more than 10 markers

I am using Geocoder callback function for getting latitude and longitude value which is asynchronous.
This works great for the 1st 10 items. I will see a markers on the map as well as those 10 listed on my sidebar. However, the 11th item and beyond will not display anything. I am querying our internal database based on parameters set which often will produce 30+ rows returned in the database table which I am looping through.
Is there any way to display more than 10 addresses on google map. or is there any need to purchase any license for get additional API for geocoder .
Thanks in advance !
The Google Geocoding services are rate limited and subject to quotas (to prevent abuse), the (paid) Google Maps API for Business, does have higher limits. The usual suggestion is to geocode the loctions offline, store the coordinates in your database, then use those coordinates to display the markers.
If you can't store the locations in your database, you need to check the return value in the geocoder and delay when it returns over query limit errors. There are examples of doing that both here in SO and in the Google Maps API v3 group.

Unlimited Markers on Google map without query Limit using Geocoder

I have a google map with multiple markers.I done that using google map Geocoder with the help of this link Geocoder usage .But,it was limited to some markers only.After the limit it is showing the error as queryLimit.Is there any way to show the multiple markers on the map without any limit.It can be other than Geocoder too.Thanks
You should never use a webservice or API to get the locations every time you want to show the markers. What you need to do is store the latitude and longitude somewhere. Preferably the same place you are storing the address information. Then just use those latitudes and longitudes to generate the markers with no need to worry about query limits.
The reason you are exceeding the query limit is that you are doing the queries too fast. If you have a period between each query you can do a lot more before hitting the querying cap, but this is not a solution. You should always save the location instead of querying every time :)

Categories

Resources