Problems retrieving Fusion Tables data - Google Maps API - javascript

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

Related

What causes maps.googleapis.com/maps/vt to return a 400 error?

I am currently using a Google Map with a Fusion Table Layer. With this map, I make AJAX queries that populate the map and a list with results.
Recently there's been an issue with the Google Map API response coming back as a 400 "Malformed Request" error. This response sporadically happens when the map is populated with a new result set after filters are set and sent via AJAX. When checking out the error Firefox's debugging console, I noticed that the pb parameter may be the issue. The problem is that I'm unsure about what exactly is malformed about this parameter.
Here's the GET request that errors out:
https://maps.googleapis.com/maps/vt?pb=[...insert_param_code_here...]&callback=_xdc_._n2pwun&token=20077
I pasted what I see assigned to the pb parameter below. This is what is sent when one of the 'invalid' queries are made.
"!1m4!1m3!1i13!2i2042!3i3139!1m4!1m3!1i13!2i2043!3i3139!1m4!1m3!1i13!2i2042!3i3140!1m4!1m3!1i13!2i2042!3i3141!1m4!1m3!1i13!2i2043!3i3140!1m4!1m3!1i13!2i2043!3i3141!1m4!1m3!1i13!2i2042!3i3142!1m4!1m3!1i13!2i2042!3i3143!1m4!1m3!1i13!2i2043!3i3142!1m4!1m3!1i13!2i2043!3i3143!1m4!1m3!1i13!2i2044!3i3139!1m4!1m3!1i13!2i2045!3i3139!1m4!1m3!1i13!2i2046!3i3139!1m4!1m3!1i13!2i2044!3i3140!1m4!1m3!1i13!2i2044!3i3141!1m4!1m3!1i13!2i2045!3i3140!1m4!1m3!1i13!2i2045!3i3141!1m4!1m3!1i13!2i2044!3i3142!1m4!1m3!1i13!2i2044!3i3143!1m4!1m3!1i13!2i2045!3i3142!1m4!1m3!1i13!2i2045!3i3143!1m4!1m3!1i13!2i2046!3i3140!1m4!1m3!1i13!2i2046!3i3141!1m4!1m3!1i13!2i2046!3i3142!1m4!1m3!1i13!2i2046!3i3143!2m21!1e2!2sft:tableID!4m2!1ssg!2s%20Cities_With_Charters%20%3D%20'East%20St.%20Louis%20Area'%20AND%20Students_Served%20LIKE%20'%25'%20AND%20School_Type_Dropdown%20IN%20('Charter')%20ORDER%20BY%20School_Name%20ASC!4m2!1ssc!2sSchool_Info_ID%2C%20CPS_ID%2C%20RCDTS%2C%20School_Name%2C%20Street_Address%2C%20City%2C%20State%2C%20Zip%2C%20Phone%2C%20Website%2C%20Lat%2C%20Long%2C%20Year_Opened%2C%20School_Description%2C%20District_Info_ID%2C%20District_Name%2C%20Charter_Renew_YR%2C%20Network_ID%2C%20Network%2C%20Community_Area%2C%20State_Rep_District%2C%20State_Sen_District%2C%20Ward_Remapped%2C%20Grades_Served%2C%20Grades_Capacity%2C%20Serves_ES%2C%20Serves_HS%2C%20Serves_MS%2C%20Serves_Dropouts%2C%20School_Type_Dropdown%2C%20School_Type_Color%2C%20School_Type_Display%2C%20Profile_Type%2C%20SQRP_Rating%2C%20SQRP_Profile%2C%20Cities_With_Charters%2C%20Link_IIRC%2C%20Students_Served!4m2!1ssq!2s'School_Type_Color'%20%3D%20'GREEN'$'School_Type_Color'%20%3D%20'ORANGE'$'School_Type_Color'%20%3D%20'BLUE'$'School_Type_Color'%20%3D%20'MAGENTA'!4m2!1sc!2si:grn_blank$i:orange_blank$i:ltblu_blank$i:purple_blank!4m2!1sy!2s2!4m2!1stmplt!2s2!5i1!3m3!2sen-US!3sUS!5e18!4e3!12m1!5b1"
Here is the query without URL encoding just for reference:
SELECT School_Info_ID, CPS_ID, RCDTS, School_Name, Street_Address, City, State, Zip, Phone, Website, Lat, Long, Year_Opened, School_Description, District_Info_ID, District_Name, Charter_Renew_YR, Network_ID, Network, Community_Area, State_Rep_District, State_Sen_District, Ward_Remapped, Grades_Served, Grades_Capacity, Serves_ES, Serves_HS, Serves_MS, Serves_Dropouts, School_Type_Dropdown, School_Type_Color, School_Type_Display, Profile_Type, SQRP_Rating, SQRP_Profile, Cities_With_Charters, Link_IIRC, Students_Served FROM tableID WHERE Cities_With_Charters = 'East St. Louis Area' AND Students_Served LIKE '%' AND School_Type_Dropdown IN ('Charter') ORDER BY School_Name ASC
The steps I've taken so far to fix this:
Making sure any query string sent to Fusion Tables has been sent with URL encoding.
Made sure to check my quotes and quotation marks and make sure there weren't any stray ones in the query being sent.
Checked my Google Map init parameters to make sure I didn't make any typos or add any non-existent parameters.
Are there any other precautions I'm missing in making sure malformed content isn't sent?
I solved this by opening Chrome Developer Tools and going to: Application > Clear storage > Clear site data. Then, with Developer Tools still open, click and HOLD the refresh button on the upper left corner of the browser until you see the words "Empty Cache and Hard Reload." Click that, and you're good to go.
I encountered the same issue. It is caused when the CSS on the page for the map results with fusion table layers doesnt align with map parameters. I fixed the CSS and the maps began to appear.

AngularJS Mapping results from $http requests

I've tried a few different ways trying to get this to work. So essentially I have a list of parks that I pull with one $http get method, each park object has a weather field inside of it. After the initial load I am trying to parse non-restful .json files with the weather status (pulled by a background process server side) and do an association with the weather object based on zipcode.
So there are about 30 parks. The way I pulled the weather info on the background (so as to not hit the rate limit) was to just pull them for each zipcode (relative to park location) and place them in a file named by zipcode. So for example 90201.json, 08291.json, etc
I've tried doing something like this so far: http://plnkr.co/edit/66BjKESPnYGWgQwOzEPN?p=info
But I think I'm probably messing up in a few places, any advice would be greatly appreciated.
Thanks!

Google Map, use MarkerClusterer with FusionTables data

I'm trying to make a map with Google Map API and MarkerClusterer. It's works perfect with a simple JSON file (like this http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/examples/simple_example.html).
But I would use Fusion Tables (simple to edit/add/del markers): http://www.google.com/drive/apps.html#fusiontables.
Is it possible ?
Of course you can. You may request FusionTable-data via the FusionTables-API. This may be done on serverside, but also via AJAX(the API supports JSONP). Once you got the data the workflow will be similar to the JSON-example in your question.
working example

How can an existing large data model be loaded with the Realtime API?

I have a realtime data model with a lot of data in it. When I try to load it using the API call my onLoaded function does not get called. Similarly my error handling function does not get called even though one of the underlying API calls (https://drive.google.com/otservice/gs?id=...&access_token=...) receives a 409 response from the server.
My attempts to load smaller data models works fine. I am confident that I am using the API correctly since I started my code from the example provided on the Realtime API Quickstart page.
Google Drive has the concept of requesting a partial response using the fields parameter to reduce the amount of data returned. I can not see similar functionality for the realtime API. Does it exist?
Is there a way to download the realtime data model as a generic file so I can pre-populate my application with data until the Realtime API is completely loaded?
Data models greater than around 10 megs are not currently supported. It sounds like you might be running into this limit.
You should think about how you can reduce the amount of data you are storing. E.g., store large items like images outside of the Realtime model, or (based on what you said you were doing in your previous question) do some smoothing to reduce the number of points stored as it increases.
You can export the data model right now in the Javascript API: https://developers.google.com/drive/realtime/reference/gapi.drive.realtime.Document#gapi.drive.realtime.Document.prototype.exportDocument
But in order to do that, you have to load the document first.

Google maps V3 search problems

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

Categories

Resources