Troubleshooting
This page gives tips on how to troubleshoot Mapfluence queries and URLs.
Making Mapfluence calls with URLs is nice: it is very fast to change a URL, it's terse, and you can see the results in your browser. However, it is really easy to make a typographical error.
Switch your calling method
If you are working with URLs, try making the call in Javascript instead. The easiest way to do that is by using the Mapfluence API Developer Lab. The lab allows you to test code without worrying if you've configured your environment properly.
In general, using Javascript will be easier. (Why do we then almost always show URLs in the examples? Because they are terser and it is easy for you to copy and paste them into a browser.)
By the same token, if you are having trouble with Javascript, you might try to make your call with a URL instead.
Percent-encode your URLs!
One of the easiest things to do wrong if you are using URLs is to not percent-encode special characters. See URL Escaping.
If you're using the Javascript API, this is done for you.
Get human-readable results
Sometimes the what an API call returns isn't easy for a human to read and/or interpret.
Visual API
The Visual API tile URLs will return a tile as a PNG, but if there is an error, it just shows a big red X, do-not-enter symbol, or similar non-map tile.
The response will have a HTTP status code not equal to 200. Also, in the HTTP response headers, you will see an additional header with information about the error, like:
X-MFError: Unknown geometryset tract_geom1 of dataset us_census00
If you're using Firebug, these will appear in red under the "Net" tab, and you can inspect the headers very easily.
- If you don't have Firebug, you can add:
- ?astext=True&show_error=True
to the end of a single tile URL to view the error in your browser.
For example, this URL will give you a image/png file with a big red X in it:
http://visual.mapfluence.com/tile/1.0.0/d/from=epasuperfnd.sf2006_geom|mode=simple|colors=black_3.1/tms/9/150/319.png
while
http://visual.mapfluence.com/tile/1.0.0/d/from=epasuperfnd.sf2006_geom|mode=simple|colors=black_3.1/tms/9/150/319.png?astext=True&show_error=True
will return an HTML document (so it will show up in a browser) with the text
400 ParameterError: invalid literal for int() with base 10: '3.1'
The error message should give you some clue as to where to start looking for the problem. (Hmm... black_3.1 - looks like point sizes can't be fractional!)
Data APIs
Most of the Mapfluence APIs return data as JSON or GeoJSON, which your browser will probably want to download instead of display. It is text, so you could save and then open with a text editor, but it doesn't have line breaks, so can be hard to read.
There are better ways.
The first way is to append
&ashtml=1
to the URL.
This will make the data return as a text/html document. For example, this URL:
http://spatial.mapfluence.com/spatialquery.json?from=us_census00.county_geom&select=unemplmnt.data.unemplevel&limit=100&ashtml=1
will display the information nicely formatted in your browser. Your browser will probably want to download a JSON file for this URL:
http://spatial.mapfluence.com/spatialquery.json?from=us_census00.county_geom&select=unemplmnt.data.unemplevel&limit=100
Another option is to download a JSON viewer plug-in for your browser. We like the Firefox plug-in JSONView.
Display the values
If you are trying to figure out why your map looks funny, you can use label mode to display the select clause values as text as one of the layers on the map. For example, this URL displays the percentage of unemployed people per county as text:
http://visual.mapfluence.com/tile/d/select=healthcvrg.uninsured.prt_u_1864|mode=label|colors=ff00ff|from=us_census00.county_geom/tms/0/0/0.png
Look at one tile
If you are trying to figure out why your map looks funny, try looking at one individual tile and playing with its URL until it looks right. Here are some valid coordinate strings for tiles in given (usually interesting) places:
| Coordinate string | location | System |
|---|---|---|
| tms/9/150/319.png | New York/New Jersey | TMS |
| g/11/327/791.png | San Francisco, CA | Google Maps |
| ve/r02301021222.png | Oakland, CA | Bing Maps |
You can also find locations via the Maptiler service. (For Bing Maps, stick an "r" in front of the quadtree number.)
If you want to know more about one particular tile on a map, you can find out what URL of that tile is by asking your browser.
| Browser | Selection |
|---|---|
| Firefox | Tools->Page Info->Media, scroll through list of tiles |
| Safari | Develop->Show Web Inspector->click resources |
| IE | Varies by version |
For example, in Firefox, select Tools->Page Info->Media, and you will see a list of images. In that list of images will be tiles for the base map (e.g. Bing or Google) and also Mapfluence tiles. You can either look through the base map tiles to find the geographic location that interests you, or you can look through the Mapfluence tiles until you see the one you want.
Look at just one feature
Sometimes you can get so much data that it is overwhelming. In those cases, it might be best to cut down the information to just one feature -- only the state of Louisiana, only ZIP code 76442, only San Juan County, etc.
Each feature has a unique ID which you can use to filter your query. For example, you could show only the unemployment rate in Cook County, IL by adding this where clause
where=id:573731
to a SpatialQuery:
http://spatial.mapfluence.com/spatialquery.jsonfrom=us_census00.county_geom&select=unemplmnt.data.unemprate&where=id:573731&ashtml=1
or even to a Visual query:
http://spatial.mapfluence.com/tile/1.0.0/d/from=us_census00.county_geom|select=unemplmnt.data.unemprate|mode=theme|breaks=6%2C8%2C10%2C12%2C14|colors=purple%2Cblue%2Cgreen%2Cyellow%2Cred|border=black_1.2|where=id:573731/tms/6/16/40.png
You can use this technique, coupled with layers, to find where on a map a specific feature is. For example, here is a map with the unemployment rate for counties, with all the counties bordered in black except for Cook County, which has a white border:
http://spatial.mapfluence.com/tile/1.0.0/d/from=us_census00.county_geom|select=unemplmnt.data.unemprate|mode=theme|breaks=6%2C8%2C10%2C12%2C14|colors=purple%2Cblue%2Cgreen%2Cyellow%2Cred|border=black_1.2/from=us_census00.county_geom|select=unemplmnt.data.unemprate|mode=theme|breaks=6%2C8%2C10%2C12%2C14|colors=purple%2Cblue%2Cgreen%2Cyellow%2Cred|border=white_2|where=id:573731/tms/6/16/40.png
You can see more about how to find the feature UID in the Feature Query docs, but here are a few UIDs:
| Place | Feature ID |
|---|---|
| State of Texas | 576399 |
| Cook County, IL | 573731 |
| ZIP code 27892 | 336782 |
| City of Urbana, OH | 582668 |
Switch your format
If you find yourself stuck when you are looking at a tile, try doing the same query but as text, e.g. as a SpatialQuery. For example, if you can't figure out why San Francisco is the color it is, try looking at the underlying data for San Francisco.
If you are looking at JSON data, and you can't figure out how the data fits together, it might help to look at it geometrically, on a tile.
HTTP Response Status Codes
When developing you should check the status code of responses. The following table describes the status codes you may see when requesting our services. These codes follow the standards set out by RFC 2616.
| Status | Name | Description |
|---|---|---|
| 200 | Success | All good |
| 304 | Not Modified | Use client's cached value (e.g. tiles) |
| 400 | Bad Request | You supplied bad parameters or bad values |
| 403 | Forbidden | Bad credentials (API key/sig) or quota violation |
| 404 | Not Found | Bad feature ID or no pre-rendered tile |
| 500 | Server Error | Request caused an unhandled server error |
| 503 | Service Unavailable | Temporary server unavailability |
Remember: for status codes 400, 403, and 500, you can check the X-MFError response header for additional info as to what went wrong.