Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I've successfully embedded a Google Maps API v3 map on my site, and added OpenStreetMaps (OSM) as the base layer. Is it possible to use Google's tiles as the base layer, and then overlay street data on top of that, rather than the entire OSM layer?

<script type="text/javascript" charset="utf-8">
    $(function(){

        google.maps.MapTypeId.push("OSM");

        var osmMapType = new google.maps.ImageMapType({
            getTileUrl: function(coord, zoom) {
                return "http://tile.openstreetmap.org/" + zoom + "/" + coord.x + "/" + coord.y + ".png";
            },
            tileSize: new google.maps.Size(256, 256),
            isPng: true,
            alt: "OpenStreetMap layer",
            name: "OpenStreetMap"
        });

        $("#map-canvas").gmap3({
            action: 'init',
                options:{
                  center: [22.49156846196823, 89.75802349999992],
                  zoom:2,
                  mapTypeId: google.maps.MapTypeId.ROADMAP,//google.maps.MapTypeId.OSM,
                  mapTypeControl: true,
                  mapTypeControlOptions: {
                    style: google.maps.MapTypeControlStyle.DEFAULT
                  },
                  navigationControl: true,
                  scrollwheel: true,
                  streetViewControl: true
                }
        });
    });
</script>
share|improve this question
add comment

1 Answer 1

It's possible but you have to render the custom OSM tiles yourself.

OSM has a generate_tiles python script that renders tiles based on a bounding box setting and a set of XML files (osm.xml includes the others) that control which features get drawn by mapnik on the map tiles.

If you edit the style files to only draw the road network layers you can generate your own set of transparent tiles and display them over any base map.

generate_tiles is a wrapper over mapnik's python bindings that reads data from a postgis/postgresql database so you will have to import OSM data for the region of interest using osm2pgsql.

share|improve this answer
    
Another option for rendering OSM tiles for smaller areas without the need for PostGIS: braincrunch.tumblr.com/post/9921938947/… –  Igor Brejc Sep 15 '11 at 6:25
add comment

protected by whuber Jul 29 '12 at 20:06

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.