The overlay layers are shown as a base layers always

126 views
Skip to first unread message

Lago GZ s

unread,
Jun 6, 2013, 8:07:57 AM6/6/13
to leafl...@googlegroups.com
Hi all.

I'm trying to create an Geojson overlay layer but it's impossible.

My code:

    var RMgoogleLayer = new L.Google('ROADMAP');
    var SgoogleLayer = new L.Google('SATELLITE');
    var HgoogleLayer = new L.Google('HYBRID');

   
    var states ='geojson data';
    var capita = new L.geoJson();
    capita.addData(states);
   
    var map = new L.Map('mapa1', {
                                zoom: 10,
                                layers: [RMgoogleLayer, capita]
                                });

    var baseMaps = {
                    "Streets": RMgoogleLayer,
                    "Satélite": SgoogleLayer,
                    "Híbrido": HgoogleLayer
                    };
                   
    var overlayMaps = {
                    "poligonos": capita
                    };
   
    L.control.layers(baseMaps, overlayMaps).addTo(map);

    map.setView(new L.LatLng(42.910563, -8.518881),9);


This shows layer 'capita' 1 second and then it dissapears.

If I change the code code with:

var baseMaps = {
                    "Streets": RMgoogleLayer,
                    "Satélite": SgoogleLayer,
                    "Híbrido": HgoogleLayer,
                    "poligonos": capita
                    };
   
    L.control.layers(baseMaps).addTo(map);

The layer 'capita" is showed like baselayer.

What's the problem?
Thanks.

Lago GZ s

unread,
Jun 6, 2013, 10:28:22 AM6/6/13
to leafl...@googlegroups.com
The problem is Google Maps.

With OSm works fine.

Somebody knows how to add overlay to Google Maps with Leaflet?

Thanks.

Lago GZ s

unread,
Jun 7, 2013, 2:26:07 AM6/7/13
to leafl...@googlegroups.com
Solved!

To load Google Maps:

var Roadmap = new L.TileLayer('http://mt{s}.google.com/vt/v=w2.106&x={x}&y={y}&z={z}&s=',
                                    { subdomains:'0123', attribution:'© Google 2012' }
                                    );

Regards!

Reply all
Reply to author
Forward
0 new messages