Anthony, I was looking for the same thing and ended up rendering my svg paths and attribute data as json then using the Raphael JavaScript Library to render the data on screen. That library is really nice; it has some very handy functions for interacting with SVG path elements, which also can be handled by jquery $(element). It also does svg transforms and matrices in the 2.0 version which really helps when you are trying to draw geographic coordinate based stuff.
-Matt On Tue, Nov 22, 2011 at 11:51 AM, Anthony Pesce <[email protected]> wrote: > Hi all, > I'm using Mapnik (702 Python bindings) to convert a shp file to an SVG. > Ultimately, I would like to use the SVG to make an interactive map on the > web -- but that requires attaching an ID attribute to the SVG path elements. > It would be great if I could choose one of the attributes from the polygons > on the shp file to use at the ID for the corresponding path in the SVG, but > I can't see a way to accomplish this. > Here's the code I'm using to make the SVG: > import mapnik > # Define the projection > prj = "+proj=aea +lat_1=27.5 +lat_2=35 +lat_0=18 +lon_0=-100 +x_0=1500000 > +y_0=6000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs" > # Create the Map > m = mapnik.Map(620, 800, prj) > # Set some basic styling > m.background = mapnik.Color('#ffffff') > s = mapnik.Style() > r = mapnik.Rule() > r.symbols.append(mapnik.PolygonSymbolizer(mapnik.Color('#dddddd'))) > r.symbols.append(mapnik.LineSymbolizer(mapnik.Color('#ffffff'),1)) > s.rules.append(r) > m.append_style('My Style', s) > # Load in the shp file > shape = mapnik.Shapefile(file='file.shp') > # Setup a layer for our shp file > lyr = mapnik.Layer('US', prj) > # Load the shp onto the map > lyr.datasource = shape > lyr.styles.append('My Style') > m.layers.append(lyr) > m.zoom_to_box(lyr.envelope()) > # spit out the SVG > mapnik.render_to_file(m,'US.svg', 'svg') > Thanks, > Anthony Pesce > _______________________________________________ > Mapnik-users mailing list > [email protected] > https://lists.berlios.de/mailman/listinfo/mapnik-users > > _______________________________________________ Mapnik-users mailing list [email protected] https://lists.berlios.de/mailman/listinfo/mapnik-users

