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.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---