Using ol3-google-maps with different projections

482 views Asked by At

I want to create map using GoogleMaps with OL3. I've used ol3-google-maps to do this. And it works. But only when using default projections. When i try to build the map with other projeciton (using proj4js), it doesn't. The same code for OSM works properly. Anyone knows where the problem lies? Is it ol3-google-maps? Or GoogleMaps have some limitations ?

Please forgive me if it's a stupid question, but it could be that for a few days I'm not able to use computer - so neither to dig by myself. So I hope someone will tell me where the problem is.

    <script>

            proj4.defs("EPSG:2178","+proj=tmerc +lat_0=0 +lon_0=21 +k=0.999923 +x_0=7500000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ");

            var extent = [3936040.28,4324573.90,7707927.89,9384064.69];

            var projection = ol.proj.get('EPSG:2178');

            projection.setExtent(extent);

            var googleLayer = new olgm.layer.Google();
            var view = new ol.View({
                projection: projection,
                center: [7466113.046828, 5959598.556178 ],
                zoom: 12
            });
            var map = new ol.Map({
                interactions: olgm.interaction.defaults()
                layers: [googleLayer],
                target: 'map',
                view: view
            });

            var olGM = new olgm.OLGoogleMaps({map: map});
            olGM.activate();
    </script>

Thanks!

1

There are 1 answers

0
ahocevar On

The Google Maps API (at least as used in ol3-google-maps) does not support other projections than Web Mercator (EPSG:3857).