Advertisement
janosoto

pagina web

Jul 1st, 2017
504
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 2.63 KB | None | 0 0
  1. <html>
  2.   <head>
  3.     <title>Maps Testing</title>
  4.   </head>
  5.   <body>
  6.  
  7.     <link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.3/dist/leaflet.css" integrity="sha512-07I2e+7D8p6he1SIM+1twR5TIrhUQn9+I6yjqD53JQjFiMf8EtC93ty0/5vJTZGF8aAocvHYNEDJajGdNx1IsQ==" crossorigin=""/>
  8.     <script src="https://unpkg.com/leaflet@1.0.3/dist/leaflet.js" integrity="sha512-A7vV8IFfih/D732iSSKi20u/ooOfj/AGehOKq0f4vLT1Zr2Y+RX7C+w8A1gaSasGtRUZpF/NZgzSAu4/Gc41Lg==" crossorigin=""></script>
  9.     <div id="mapid" style="height: 100%"></div>
  10.      
  11.     <script type="text/javascript">
  12.       //Constantes de oblacion
  13.         var latOblacion = 110540;
  14.         var longOblacion = 111320;
  15.  
  16.         //Arreglo que contiene los puntos de la frontera
  17.         var frontier = [];
  18.  
  19.         //Arreglo que contiene los ítems disponibles
  20.         var items = [];
  21.  
  22.         //Arreglo con las distancias entre los ítems y el usuario objetivo
  23.         var itemsDistance = [];
  24.  
  25.         //Arreglo que contiene los usuarios disponibles
  26.         var users = [];
  27.  
  28.         //Arreglo con las distancias entre los usuarios disponibles y el usuario objetivo
  29.         var usersDistance = [];
  30.  
  31.         //Arreglo con la ruta de recomendación
  32.         var route = [];
  33.  
  34.       //Imágenes de los íconos
  35.         var itemIcon = L.icon({
  36.             iconUrl: 'item_marker.png',
  37.  
  38.             iconSize: [52, 84],
  39.             iconAnchor: [26, 82]
  40.         });
  41.  
  42.         var userIcon = L.icon({
  43.             iconUrl: 'user_marker.png',
  44.  
  45.             iconSize: [52, 84],
  46.             iconAnchor: [26, 82]
  47.         });
  48.  
  49.         function init(latitude, longitude){        
  50.             //Máximo zoom es 18
  51.             mymap = L.map('mapid').setView([latitude, longitude], 17);
  52.  
  53.             L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', {
  54.                     maxZoom: 18,
  55.                     attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
  56.                         '<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
  57.                         'Imagery © <a href="http://mapbox.com">Mapbox</a>',
  58.                     id: 'mapbox.streets'
  59.                 }).addTo(mymap);
  60.  
  61.             return mymap;
  62.         }
  63.  
  64.       function showMap(mymap, latitude, longitude, type){
  65.         var polygon = L.polygon(frontier, {color: 'blue'}).addTo(mymap);
  66.         var recommendationRoute = L.polyline(route, {color: 'yellow'}).addTo(mymap);
  67.         addUsersAndItemsToMap(mymap);
  68.         L.marker([latitude, longitude]).addTo(mymap);
  69.         if(type == 0){
  70.           mymap.fitBounds(polygon.getBounds());
  71.         }
  72.         else{
  73.           mymap.setView([latitude, longitude], 15);
  74.         }
  75.       }
  76.  
  77.      </script>
  78.   </body>
  79. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement