Domanda

Sono molto interessato al API della mappa dei volantini.

Tuttavia, devo essere in grado di utilizzare il livello satellitare di Google. Non sono stato in grado di trovare un esempio su come aggiungere un livello satellitare di Google al volantino. Capisco che dovrò comunque caricare l'API di Google Maps per farlo (OpenLayers ha un esempio).

È stato utile?

Soluzione

Il fogliadle ha una pagina ufficiale per la pubblicazione di tutti i plug -in disponibili: http://leafletjs.com/plugins.html

Troverai plugin lì per l'aggiunta del supporto di Google Layer al volantino.

Altri suggerimenti

Non hai bisogno di un plug -in o dell'API di Google, puoi aggiungerlo come livello XYZ.

Strade

googleStreets = L.tileLayer('http://{s}.google.com/vt/lyrs=m&x={x}&y={y}&z={z}',{
    maxZoom: 20,
    subdomains:['mt0','mt1','mt2','mt3']
});

Ibrido:

googleHybrid = L.tileLayer('http://{s}.google.com/vt/lyrs=s,h&x={x}&y={y}&z={z}',{
    maxZoom: 20,
    subdomains:['mt0','mt1','mt2','mt3']
});

Satellitare:

googleSat = L.tileLayer('http://{s}.google.com/vt/lyrs=s&x={x}&y={y}&z={z}',{
    maxZoom: 20,
    subdomains:['mt0','mt1','mt2','mt3']
});

Terreno

googleTerrain = L.tileLayer('http://{s}.google.com/vt/lyrs=p&x={x}&y={y}&z={z}',{
    maxZoom: 20,
    subdomains:['mt0','mt1','mt2','mt3']
});


Note the difference in the "lyrs" parameter in the URL:
Hybrid: s,h;
Satellite: s;
Streets: m;
Terrain: p;

C'è un plugin di terze parti per questo: Demo: http://psha.org.ru/leaflet/bel.html (Passa a Google Maps con la Switcher) Fonte: http://psha.org.ru/leaflet/google.js

Questo repository contiene pochi livelli di piastrelle Google e altri plugin molto utili:https://github.com/shramov/leaflet-plugins

GEOGLE TITOLE LATER CON Traffico

var googleTraffic = L.tileLayer('https://{s}.google.com/vt/lyrs=m@221097413,traffic&x={x}&y={y}&z={z}', {
        maxZoom: 20,
        minZoom: 2,
        subdomains: ['mt0', 'mt1', 'mt2', 'mt3'],
    });

Si prega di vedere il loro Termini generali

Spero che qualcuno lo aiuti

Alternativa all'API di Google Maps per livello satellitare: Leaflet.js con piastrelle di immagini mondiali esri

<script>

    var map = L.map('map').setView([-41.2858, 174.78682], 14);

    var mapLink = '<a href="http://www.esri.com/">Esri</a>';
    var wholink = 'i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community';

    L.tileLayer(
        'http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
        attribution: '&copy; '+mapLink+', '+wholink,
        maxZoom: 18,
        }).addTo(map);

</script>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top