News for hackers. Stuff that matters.

Ask HN: Are there any JavaScript libraries for generating maps?

Specifically, I'd love to be able to pass in geocoded location boundaries and color styles to generate a map of the chosen color over the chosen area. Google maps is obviously great for showing navigational data or directions, but I'm thinking along the lines of something more graphic.

Does anyone have any thoughts along these lines?

( 22 comments | 49 points | on HN )
Re:Ask HN: Are there any JavaScript libraries for generating... by mbostock on Friday November 14, 2014 @11:26AM (#8607904)
Here’s my introductory tutorial for creating a map with D3 & TopoJSON using geometry from Natural Earth:

http://bost.ocks.org/mike/map/

And here’s a subsequent tutorial for visualizing geographic data:

http://bost.ocks.org/mike/bubble-map/

Re:Ask HN: Are there any JavaScript libraries for generating... by xfalcox on Friday November 14, 2014 @11:52AM (#8608092)
I'm currently using D3 & TopoJSON to plot many things (including where our visitors are, since we have the lat and long of our users, by parsing the nginx log) and it's really great!!

Thanks for your hard work Mike!!!

Re:Ask HN: Are there any JavaScript libraries for generating... by pp19dd on Friday November 14, 2014 @12:31PM (#8608327)
Just thought I'd say, when I first ran into D3, I sneered a bit. "These guys are just copying protovis." Took me a bit longer to notice the connection.
Re:Ask HN: Are there any JavaScript libraries for generating... by azov on Friday November 14, 2014 @12:36PM (#8608345)
If you want to create your own map tiles in advance and show them using JavaScript library - use TileMill [1] and Leaflet [2]. Both are excellent and very well documented.

To create the whole map on the fly using JavaScript - try mapbox-gl.js [3]. You should be able to pass your location boundaries via mapboxgl.GeoJSONSource (and then you probably don't even need MapBox API key - haven't tried it, though) and style it like this: https://www.mapbox.com/mapbox-gl-styles/styles/bright-v4.jso...

PS. If you decide to host your own tiles - remember that browsers limit the number of connections to each domain. Your map will load much faster if you serve tiles from several different domains, e.g. tiles1.example.com, tiles2.example.com, etc.

[1] TileMill - https://www.mapbox.com/tilemill/

[2] Leaflet - http://leafletjs.com/

[3] MapboxGL - https://www.mapbox.com/mapbox-gl/

Re:Ask HN: Are there any JavaScript libraries for generating... by jeroenvisser101 on Friday November 14, 2014 @01:00PM (#8608476)
If someone is going to use different domains for their tiles, they might want to do something with hashes of the tile id/name to get a subdomain, in order to preserve caching.
Re:Ask HN: Are there any JavaScript libraries for generating... by thrwy10 on Friday November 14, 2014 @11:04AM (#8607764)
You might be looking for Mapbox and/or Leaflet

https://www.mapbox.com/developers/

http://leafletjs.com/

Re:Ask HN: Are there any JavaScript libraries for generating... by petepete on Friday November 14, 2014 @12:15PM (#8608241)
Also, openlayers

http://openlayers.org

Re:Ask HN: Are there any JavaScript libraries for generating... by ohashi on Friday November 14, 2014 @05:14PM (#8609834)
+1 for Leaflet. Really easy to use.
Re:Ask HN: Are there any JavaScript libraries for generating... by chishaku on Friday November 14, 2014 @11:36AM (#8607969)
This can help you get up and running quickly:

http://jvectormap.com/

Re:Ask HN: Are there any JavaScript libraries for generating... by mdhgriffiths on Friday November 14, 2014 @11:32AM (#8607945)
Google Maps API does have [some limited] style options, however then you're stuck using Google Maps API. There is even a "wizard" to make things easier: http://gmaps-samples-v3.googlecode.com/svn/trunk/styledmaps/...

Mapbox is a great alternative for stylish maps. Their JS library is built off of Leaflet which allows you to change the tileset at a later date.

Re:Ask HN: Are there any JavaScript libraries for generating... by kaybe on Friday November 14, 2014 @11:33AM (#8607949)
Might not fit your criteria, but in the scientific community GMT is popular:

http://gmt.soest.hawaii.edu/

Re:Ask HN: Are there any JavaScript libraries for generating... by hackertoolbox on Friday November 14, 2014 @10:30PM (#8610743)
Great discussion. Tools are in the box now.

http://www.hackertoolbox.com/tags/map

Re:Ask HN: Are there any JavaScript libraries for generating... by CoreSet on Friday November 14, 2014 @01:53PM (#8608811)
Thanks all for the responses! I have a lot of new tech to try out.

For those wanting an example:

http://kut.org/term/google-fiber

Basically just a grey/white map showing important navigational details like roads and rivers, with different color sections overlaying it.

Re:Ask HN: Are there any JavaScript libraries for generating... by chippy on Saturday November 15, 2014 @04:57PM (#8612773)
So, what did you use?

How did you do it?

Did we help?

Re:Ask HN: Are there any JavaScript libraries for generating... by cinjon on Friday November 14, 2014 @12:42PM (#8608374)
Lightning by mathisonian is a solid library for generating these in python/js. It's an http-based data viz server with additional functionality similar to iPython notebooks. Check out the map demo on the github here:

https://github.com/mathisonian/lightning

Re:Ask HN: Are there any JavaScript libraries for generating... by onion2k on Friday November 14, 2014 @11:12AM (#8607820)
You can style maps using https://www.mapbox.com/ and embed them very easily using leaflet.js.

If you want to go a bit further, stamen mapstack does some cool stuff: http://mapstack.stamen.com/

Re:Ask HN: Are there any JavaScript libraries for generating... by rkda on Friday November 14, 2014 @11:10AM (#8607808)
Can you post an example of what you want?

If you just want to produce choropleths, you can try Leaflet. Other options include d3.js and kartograph.

http://kartograph.org/

http://d3js.org/

Re:Ask HN: Are there any JavaScript libraries for generating... by dpeck on Friday November 14, 2014 @11:43AM (#8608027)
Can you clarify on "more graphic"?

I'm a fan of datamaps, https://datamaps.github.io/, for doing some quick and getting decent output.

Re:Ask HN: Are there any JavaScript libraries for generating... by eloycoto on Friday November 14, 2014 @11:02AM (#8607752)
You can use cartodb. It's a service but it's faster than use libraries like leafletjs

http://cartodb.com/

Regards.

Re:Ask HN: Are there any JavaScript libraries for generating... by adrice727 on Friday November 14, 2014 @11:30AM (#8607929)
Another D3 tutorial that was helpful:

http://www.tnoda.com/blog/2013-12-07

Re:Ask HN: Are there any JavaScript libraries for generating... by jaybo_nomad on Friday November 14, 2014 @01:39PM (#8608714)
Bleeding edge WebGL requirements, but great 3D object control: http://cesiumjs.org/
Re:Ask HN: Are there any JavaScript libraries for generating... by bni on Friday November 14, 2014 @01:20PM (#8608591)