Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List of Locations and Timezones #12

Open
ardok opened this issue May 13, 2013 · 1 comment
Open

List of Locations and Timezones #12

ardok opened this issue May 13, 2013 · 1 comment

Comments

@ardok
Copy link
Contributor

ardok commented May 13, 2013

Is there anyway to get a list of locations and timezones so that we can generate a select dropdown?

For example:

<option value="PDT">America/Los Angeles</option>
<option value="PDT">America/Vancouver</option>
etc...

Right now, you have to go through the JSON files and somehow extract it, which is not trivial.

Thanks for a great plugin!

@ericktai
Copy link

I took some time to extract it.

http://jsfiddle.net/ericktai/CfNLF/

Sorry for not providing a non-programmatic way to do so in this jsfiddle example. I basically ran all the code inside the JS console since $.get(..) can only work on the same domain due to AJAX restrictions, so all my code was in the console :) But here's the pseudo code in case they ever need to be generated again. Of course I'm sure there are better ways to do this, but here you go.

Assuming you've ran through the timezone-picker steps and generated your openlayer polygon json files...

  1. Create hard coded array of polygon .json files on server.
var jsonFiles = ["http://..../components/timezone-picker/tz_json/polygons/africa-casablanca.json",
 ...,
...]
  1. Run this on the same server so AJAX will work. I ran this in the JS console.

$.each(jsonFiles, function(i, file) { $.get(file, function(data) { /* JSON.parse(data) */ }) });

Example content of the .json file

image

  1. collect all parsed JSON, which will have locations and timezones in a hairy format
  2. Manipulate the data into the map you see in the jsfiddle example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants