I found a similar question already answered, but it is not working for me. I need to call Google Satellite as a base layer. Probably I am not entering the base layer code at the right place so that it works. Here is a link to my page, I would be grateful if I get help on exactly where to add the base layer code to call Google Satellite as a base layer, instead of OSM. Thanks!
Asked
Active
Viewed 2,627 times
-3
-
1Possible duplicate of [Leaflet Map API with Google Satellite Layer](http://stackoverflow.com/questions/9394190/leaflet-map-api-with-google-satellite-layer) – IvanSanchez Aug 19 '16 at 09:17
-
Thanks, I have seen that question, but I was unable to add the base layer code at the right place. Needed help in knowing exactly where should that part of code be added. – abhijit ekbote Aug 19 '16 at 09:19
-
3Please provide a [mcve] **in the question itself**, not (just) a link to an external site. – geocodezip Aug 19 '16 at 10:11
1 Answers
0
I am not sure what you are looking for. I assume you are trying to add google map satellite tiles into your leaflet application as a basemap layer?
Unfortunately , you can't pull the google map tiles yourself using only leaflet api because of google is not allowing direct access to the tiles without using google map API. What you can do alternatively is to write your plugin in your application for the basemap switch to include a google map call via google maps api.
For using a third party lib doing the same thing, see sample code:
<!DOCTYPE html>
<html>
<head>
<title>Leaflet</title>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.3.1/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.3.1/leaflet.js"></script>
<script src="http://maps.google.com/maps/api/js?v=3.2&sensor=false"></script>
<script src="http://matchingnotes.com/javascripts/leaflet-google.js"></script>
</head>
<body>
<div style="width:500px; height:500px" id="map"></div>
<script type='text/javascript'>
var map = new L.Map('map', {center: new L.LatLng(51.51, -0.11), zoom: 9});
var googleLayer = new L.Google('ROADMAP');
map.addLayer(googleLayer);
</script>
</body>
</html>
So what leaflet-google.js doing here is parsing the leaflet tile request to google map tile parameters and pull the tiles to layer. So again, without using google maps api, it is not allowed to use the tiles.

Teng Ma
- 353
- 2
- 9
-
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – Uyghur Lives Matter Sep 20 '16 at 20:14