Advertisement
Guest User

Untitled

a guest
Oct 21st, 2014
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.09 KB | None | 0 0
  1. <html>
  2. <head>
  3. <meta charset=utf-8 />
  4. <title>A sample map</title>
  5. <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
  6. <script src='https://api.tiles.mapbox.com/mapbox.js/v2.1.2/mapbox.js'></script>
  7. <link href='https://api.tiles.mapbox.com/mapbox.js/v2.1.2/mapbox.css' rel='stylesheet' />
  8. <style>
  9.   body { margin:0; padding:0; }
  10.   #map { position:absolute; top:0; bottom:0; width:100%; }
  11. pre.ui-coordinates {
  12.   position:absolute;
  13.   bottom:10px;
  14.   left:10px;
  15.   padding:5px 10px;
  16.   background:rgba(0,0,0,0.5);
  17.   color:#fff;
  18.   font-size:11px;
  19.   line-height:18px;
  20.   border-radius:3px;
  21.   }
  22. </style>
  23.  
  24. </head>
  25. <body>
  26. <div id='map'></div>
  27. <pre id='coordinates' class='ui-coordinates'></pre>
  28. <script>
  29.     function ondragend() {
  30.     var m = marker.getLatLng();
  31.     coordinates.innerHTML = 'Latitude: ' + m.lat + '<br />Longitude: ' + m.lng;
  32. }
  33.    
  34. var mapboxTiles = L.tileLayer('https://{s}.tiles.mapbox.com/v3/examples.map-i87786ca/{z}/{x}/{y}.png', {
  35.     attribution: '<a href="http://www.mapbox.com/about/maps/" target="_blank">Terms &amp; Feedback</a>'
  36. });
  37.     var osmUrl='http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
  38.     var osmAttrib='Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors';
  39.     var osm = new L.TileLayer(osmUrl, {minZoom: 8, maxZoom: 15, attribution: osmAttrib});  
  40.  
  41. var map = L.map('map')
  42.     .addLayer(mapboxTiles)
  43.     .setView([14.068928, 100.607437], 10);
  44. var greenIcon = L.icon({
  45.     iconUrl: 'leaf-green.png',
  46.     shadowUrl: 'leaf-shadow.png',
  47.  
  48.     iconSize:     [38, 95], // size of the icon
  49.     shadowSize:   [50, 64], // size of the shadow
  50.     iconAnchor:   [22, 94], // point of the icon which will correspond to marker's location
  51.     shadowAnchor: [4, 62],  // the same for the shadow
  52.     popupAnchor:  [-3, -76] // point from which the popup should open relative to the iconAnchor
  53. });
  54. var coordinates = document.getElementById('coordinates');
  55. var marker = L.marker([14.07, 100.61], {icon: greenIcon, draggable: true}).addTo(map);
  56. marker.on('dragend', ondragend);
  57.  
  58. ondragend();
  59. </script>
  60. </body>
  61. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement