JSON + display

99 views
Skip to first unread message

Jon Richter

unread,
Jan 12, 2013, 1:47:58 PM1/12/13
to timemap-d...@googlegroups.com
Dear Timemap.js Community,

I'm happy to see that this evolved project still receives attention from some developers,
despite it's last version 2.0.1 has been released many months ago.

I'm currently implementing Timemap.js on a test plattform and have some issues to control it right.

http://geosemantik.de/timemap/ , if you'd like to have a look.
  • Timeline objects only show up after opening Chrome's element inspector. Why?
  • JSON dataset gets loaded (Chrome's XHR network inspectior), but is not displayed. Why?
As you can see I like to generalize and modularize my code as much as possible, to take advantage of it in future circumstances.
But this also seems to cause some trouble I cannot debug.

Any ideas would be very much appreciated.

Thanks alot in advance,

Jon


PS: In the future I'm very likely to change the maps appearance towards my implementation at http://gartenkarte.de/ . Do you expect any problems?

Nick Rabinowitz

unread,
Jan 12, 2013, 5:26:57 PM1/12/13
to jon.r...@gmail.com, Timemap.js Development
Hmm. My first thought here is that you have the same ID for both datasets - this will cause the second dataset to override the first (the TimeMap object maintains a datasets object keyed to this id, so duplicate ids will replace older entries). That should fix your second problem (JSON not loading).

It might fix your 1st problem, too, so I'd try that first, but there may be something else going wrong here.

-Nick


--
You received this message because you are subscribed to the Google Groups "Timemap.js Development" group.
To view this discussion on the web visit https://groups.google.com/d/msg/timemap-development/-/zq83fGDDMIcJ.

To post to this group, send email to timemap-d...@googlegroups.com.
To unsubscribe from this group, send email to timemap-develop...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/timemap-development?hl=en.

Jon Richter

unread,
Jan 12, 2013, 6:17:24 PM1/12/13
to timemap-d...@googlegroups.com
Good evening Nick,

thanks for your quick review. Obviously this was faulty.
But it doesn't change anything :
  1. markers don't show up until timeline is scrolled
  2. timeline doesn't feature the elements
  3. json dataset is not displayed
I think I will have a sleep about this and try to figure it out later.
Additionally, I'm a JavaScript and stuff novice.

[
But I like the idea to use mapstraction, so leaflet + co also become possible.
Would be interesting to see TimeMap evolving towards standard library use despite of the ones in the package, so one can stay up to date. (mapstraction, timeline)
]

So, another Experiment :)

If anyone else still has suggestions, please feel free to contribute.

A nice weekend to everyone,
Jon

Jon Richter

unread,
Jan 12, 2013, 6:18:42 PM1/12/13
to timemap-d...@googlegroups.com
addition : Chrome element inspector revealing of the timeline elements only works when the inspector is attached to the browser window.

Nick Rabinowitz

unread,
Jan 12, 2013, 7:07:22 PM1/12/13
to jon.richter, Timemap.js Development
That's almost certainly because opening the inspector resizes the window, forcing the timeline to refresh. Not that this answers your issues, but it's one less mystery :).

-Nick


--
You received this message because you are subscribed to the Google Groups "Timemap.js Development" group.

Nick Rabinowitz

unread,
Jan 12, 2013, 7:19:01 PM1/12/13
to jon.richter, Timemap.js Development
Pretty sure this is failing because your JSON isn't valid JSON (you can't have comments in JSON - it's a data format, not an actual Javascript file). So the JSON parsing fails, and then TimeMap never thinks all datasets are loaded, so it doesn't refresh the timeline until you trigger this manually. Fix your JSON and it ought to work.

Jon Richter

unread,
Jan 12, 2013, 9:00:44 PM1/12/13
to Nick Rabinowitz, Timemap.js Development
Nick,

thanks, that was it. I've read about JSON being very 'strict' in terms of syntax, but I didn't know THAT strict. I thought the YAML sepc would leave some space for creative insertions :-/

And yes, I've also read that JSON parsing errors mostly quit silently. I mean, reading the JQuery doc explicitly states it as important : http://api.jquery.com/jQuery.getJSON/ .

Now I know. Thank you,

Jon


PS: It would be interesting to know if one could encapsulate TimeMap related infos into GeoJSON to have something geo-standard compliant.


2013/1/13 Nick Rabinowitz <ni...@nickrabinowitz.com>

Alan Leslie

unread,
Jan 12, 2013, 10:02:17 PM1/12/13
to timemap-d...@googlegroups.com
Hi Jon

Not sure I'm adding any value here but...

There are a few places that you can check you JSON syntax, e.g. http://jsonlint.com/ or http://jsonformatter.curiousconcept.com/.

Also if you are not sure whether there is a problem in your JSON you could add an error detection function to your timemap, I had mentioned this in a recent post on the subject "Reading JSON local URL in OpenLayers format":

"Because of this error the JQuery AJAX call calls the error function instead of the success function. You might want to add a custom error function so as to spot this kind of problem in the future. I defined an error function as follows:

 var errFn = function(jqXHR, textStatus, errorThrown){
     alert(textStatus);
     }

And then changed the dataset options to be:

options: {
url: ...,
error: errFn
}"

This will flag up any parse errors in your JSON (or XML?).

Note that this will not work if you are using JSONP or cross domain. The documentation for JQuery Ajax (http://api.jquery.com/jQuery.ajax/ error) mentions "Note: This handler is not called for cross-domain script and JSONP requests."

For JSONP requests you can add an error handler but you have to use something like https://github.com/jaubourg/jquery-jsonp.

Hope that helps.

Alan


Alan Leslie

unread,
Jan 12, 2013, 10:49:31 PM1/12/13
to timemap-d...@googlegroups.com

Jon Richter

unread,
Jan 13, 2013, 11:46:25 AM1/13/13
to timemap-d...@googlegroups.com
Dear Alan,

people like you and Nick are the reason, why I like being around with FOSS people : sincere help is willingly given.

Surely, as JSON is a topic I start to discover yet, I'll also have to think about error handling and so on.
Thanks for the little helpers you posted to validate my data.

As I'm also in my beginnings of AJAX (Does one use this term anymore? It's XHR these days, right?) work, it will take some time until I will have to work around cross domain policies and JSONP, but thanks in advance.

Greetings from Berlin,
Jon
Reply all
Reply to author
Forward
0 new messages