Search code examples
openlayersopenstreetmapshapefile

OpenLayer + OpenStreetMap + Custom ShapeFile


I started in the mapping. I would like to view a map of France with a layer on top that would be personalized.

I already have the custom layer with shapefile format. I do not know at all if I have to create an OpenStreetMap server or if I can use the web application directly.

Can you give me a starting point for mapping display with my extra layer shapefile format?

I guess the task is complex, but you have to start somewhere by ...

thank you very much


Solution

  • It depends on what you want to do. Is it a big Shapefile?

    You can do a few things while create an openlayers map:

    • use the public openstreetmap server for background-tiles (the default OSM Layer implementation) and add your feature layer (points, polygons, whatever is in there) as a Vector feature layer in OSM. To get your vector features out of your shapefile you can:
      • preload them in your database in a decent GIS based format. This allows you to serve your features while doing bounding box queries, and is required if you have more than 1000/10000 features.
      • convert the shapefile to a format readable by openlayers (either in browser using https://github.com/wavded/js-shapefile-to-geojson , or preconvert them with a tool like ogr2ogr)
    • or, if you don't require interaction with these features, you can combine your data with OSM data, and create your custom tiles. This is more light-weight for the browser, but it's quite complex (read all OSM data in a DB, generate tiles with mapnik)