Advertisement
rossig7

Example leaflet-omnivore

Nov 5th, 2014
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // initmapa.js
  2.  
  3. var osmUrl = '';
  4. var osmAttrib = '';
  5. var mapa = null;
  6.  
  7.  
  8. function loadMapa()
  9. {      
  10.     osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';  
  11.     osmAttrib = osmAttrib='Map data &copy <a href="http://openstreetmap.org">OpenStreetMap</a> contributors';
  12.        
  13.     mapa = L.map('map').setView([-34.9053694,-56.2072348], 13); // mapa var global
  14.                                                                            
  15.     L.tileLayer(osmUrl, {
  16.                 attribution: osmAttrib,
  17.                 minZoom: 8,
  18.                 maxZoom: 18,                   
  19.         }).addTo(mapa);
  20.                    
  21.    
  22.  
  23. };
  24. function loadEstacionesDeServicio()
  25. {  
  26.        
  27.     var infladores = omnivore.kml('Mapas/infladores.kml').on('ready', function() {     
  28.             mapa.fitBounds(infladores.getBounds());  
  29.         }).addTo(mapa);        
  30.    
  31. };
  32.  
  33. index.html
  34.  
  35. <!DOCTYPE html>
  36. <html>
  37.     <head>
  38.         <meta charset="utf8">
  39.         <meta name="viewport" content="width=device-width, initial-scale=1.0">
  40.    
  41.         <title>Mapa simple</title> 
  42.         <link rel="stylesheet" href="leaflet.css" />      
  43.            <link rel="stylesheet" href="css/mapa.css">        
  44.            <script src="leaflet.js"></script>                  
  45.            <script src='js/leaflet-omnivore.min.js'></script>      
  46.       </head>
  47.       <body>           
  48.         <div id="map"></div>                                   
  49.              <script src="js/initmapa.js"></script>                                                                                          
  50.  
  51.         <script>           
  52.             loadMapa();        
  53.             loadEstacionesDeServicio() 
  54.         </script>                      
  55.     </body>
  56. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement