Hm, interesting. I dug up an BNF diagram of JSON and sure enough it doesn't. The JSONlint validator http://www.jsonlint.com seemed to be consistently rejected my JSON data mockups unless I quoted them back when I was first playing with it, and json_encode insisted on doing so, too. Curious that my database columns are floats not strings.
Now I've just tried 1.0 + $value, 1.0 * $value, (float) $value, floatval($value) and settype($value,'float') and json_encode quotes everything regardless. I saw mention of the polygonzo and glanced at it but couldn't quite get a handle on what I really needed to do to move from what I have to that and get it working. First off, creating the JSON files from shapefiles for my townships seems necessary, although I managed to parse out the ascii csxx_d00.dat and csxx_d00a.dat tiger files which I happened to load into mySQL rather than make files from it. Then, just where to go with the data from there. Maybe after studying the code a bit more closely I'll start to see the way to go. On Dec 28, 5:49 pm, "Michael Geary" <[email protected]> wrote: > JSON does not require property *values* to be quoted, unless they are indeed > strings. Numeric property values in JSON are not quoted. JSON does require > property *names* to be quoted. > > To illustrate, this is valid JSON, but it will not work for your purposes, > because it has string values instead of numeric values: > > [ > { > "x": "-85.9375839233398440", > "y": "39.9271392822265630" > }, > { > "x": "-85.9373779296875000", > "y": "39.9264373779296870" > } > ] > > This is also valid JSON, and it has numeric property values which will work > as you expect: > > [ > { > "x": -85.9375839233398440, > "y": 39.9271392822265630 > }, > { > "x": -85.9373779296875000, > "y": 39.9264373779296870 > } > ] > > PHP's json_encode function should generate that format if you provide it > with numeric values instead of string values. However, it's easy to > inadvertently pass strings to json_encode when you should have given it > numbers. See the comment by Garrett (22-Oct-2008 11:17) on the json_encode > doc page: > > http://php.net/json_encode > > As an aside, JSON is a subset of the JavaScript object literal format. JSON > requires property names to be quoted, but JavaScript does not require that > unless the names are invalid identifiers (e.g. they contain a space or other > special characters, or they are JavaScript reserved words). > > This is not valid JSON, but it *is* valid JavaScript, and it means exactly > the same thing as the preceding valid JSON example: > > [ > { > x: -85.9375839233398440, > y: 39.9271392822265630 > }, > { > x: -85.9373779296875000, > y: 39.9264373779296870 > } > ] > > BTW, instead of the checkbox to turn off the polygons, you could use > PolyGonzo to get fast performance in IE. I think you were looking at doing > that earlier, but I didn't keep up on the conversation. Let me know if you'd > like to give it a shot and I will see if I can assist. > > -Mike > > > > > From: donb > > > I wasn't after help debugging anything, I wanted the other poster (or > > someone) to explain the correct use of an array of Object vs. > > an array of GLatLng. Apparently a valid JSON construct, > > which includes the double-quotes, is not palatable to > > GLatLng. Upon making them floats, it works fine. My source > > data was output by PHP's json_encode() function, which I'd > > expected would be suitable. It's not. > > > However, the map is now published outside, rather that on my > > localhost: http://bartlies.com/map/index.php > > > I opted to just provide a checkbox to turn on/off the > > GPolygons since IE still was pretty sluggish.- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Maps API" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Maps-API?hl=en -~----------~----~----~----~------~----~------~--~---
