Advertisement
Guest User

Untitled

a guest
Nov 29th, 2013
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.64 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset=utf-8 />
  5. <title>Single Marker</title>
  6.  
  7. <meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no' />
  8. <script src='http://api.tiles.mapbox.com/mapbox.js/v1.5.0/mapbox.js'></script>
  9. <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
  10. <link href='http://api.tiles.mapbox.com/mapbox.js/v1.5.0/mapbox.css' rel='stylesheet' />
  11.  
  12.  
  13. <script src="http://www.parsecdn.com/js/parse-1.2.13.min.js"></script>
  14.  
  15. <style>
  16. body { margin:0; padding:0; }
  17. #map { position:absolute; top:0; bottom:0; width:100%; }
  18. </style>
  19. </head>
  20. <body>
  21. <style>
  22. #open-popup {
  23. position:absolute;
  24. top:5px;
  25. right:5px;
  26. }
  27.  
  28. #login-popup {
  29. position:absolute;
  30. top:5px;
  31. left:50%;
  32. z-index: 999;
  33. }
  34.  
  35. #coords-x {
  36. position:absolute;
  37. top:30px;
  38. right:50px;
  39. }
  40. #coords-y {
  41. position:absolute;
  42. top:30px;
  43. right:5px;
  44. }
  45. .image{
  46.  
  47. float: left;
  48. margin-right: 3% ;
  49. }
  50. .caption p{
  51. text-align: center;
  52. }
  53.  
  54. </style>
  55. <div id='map'></div>
  56. <button id='open-popup' onclick="clickButton()">Place Marker</button>
  57. <input id='coords-x' type="text" size = "3" name="x">
  58. <input id='coords-y' type="text" size = "3" name="y">
  59.  
  60. <div class = "login-popup">
  61. <a href="#login-box">
  62. <div class="btn-sign">
  63. <span class="login-window">Login / Sign In</span>
  64. </div>
  65. </a>
  66. <div>
  67.  
  68. <div id="login-box" class="login-popup">
  69. <a href="#" class="close"><img src="close_pop.png" class="btn_close" title="Close Window" alt="Close" /></a>
  70. <form method="post" class="signin" action="#">
  71. <fieldset class="textbox">
  72. <label class="username">
  73. <span>Username or email</span>
  74. <input id="username" name="username" value="" type="text" autocomplete="on" placeholder="Username">
  75. </label>
  76.  
  77. <label class="password">
  78. <span>Password</span>
  79. <input id="password" name="password" value="" type="password" placeholder="Password">
  80. </label>
  81.  
  82. <button class="submit button" type="button">Sign in</button>
  83.  
  84. <p>
  85. <a class="forgot" href="#">Forgot your password?</a>
  86. </p>
  87.  
  88. </fieldset>
  89. </form>
  90. </div>
  91.  
  92. <script>
  93. $(document).ready(function() {
  94. $('a.login-window').click(function() {
  95.  
  96. // Getting the variable's value from a link
  97. var loginBox = $(this).attr('href');
  98.  
  99. //Fade in the Popup and add close button
  100. $(loginBox).fadeIn(300);
  101.  
  102. //Set the center alignment padding + border
  103. var popMargTop = ($(loginBox).height() + 24) / 2;
  104. var popMargLeft = ($(loginBox).width() + 24) / 2;
  105.  
  106. $(loginBox).css({
  107. 'margin-top' : -popMargTop,
  108. 'margin-left' : -popMargLeft
  109. });
  110.  
  111. // Add the mask to body
  112. $('body').append('<div id="mask"></div>');
  113. $('#mask').fadeIn(300);
  114.  
  115. return false;
  116. });
  117.  
  118. // When clicking on the button close or the mask layer the popup closed
  119. $('a.close, #mask').live('click', function() {
  120. $('#mask , .login-popup').fadeOut(300 , function() {
  121. $('#mask').remove();
  122. });
  123. return false;
  124. });
  125. });
  126.  
  127. var map = L.mapbox.map('map', 'examples.map-20v6611k')
  128. .setView([51.59, 4.78], 6);
  129.  
  130. var geoJson = [{
  131. type: 'Feature',
  132. "geometry": { "type": "Point", "coordinates": [4.78, 51.59]},
  133. "properties": {
  134. 'title': 'Company name',
  135. // Store the image url and caption in an array
  136. 'images': [
  137. ['http://upload.wikimedia.org/wikipedia/commons/1/1f/Amarok-icon.png','Company name','"Lorem ipsum dolor sit amet, consectetur sade"']
  138. ]
  139. }
  140. }];
  141.  
  142. map.markerLayer.on('layeradd', function(e) {
  143. var marker = e.layer;
  144. var feature = marker.feature;
  145. var images = feature.properties.images
  146. var slideshowContent = '';
  147.  
  148. var img = images[0];
  149.  
  150. slideshowContent += '<div class="image">' +
  151. '<img src="' + img[0] + '" />' +
  152. '</div>'+
  153. '<div class="caption">'
  154. + '<p>' + img[1] + '</p>' + img[2] +
  155. '</div>';
  156.  
  157. // Create custom popup content
  158. var popupContent = '<div id="' + feature.properties.id + '" class="popup">' +
  159. '<div class="slideshow">' +
  160. slideshowContent +
  161. '</div>' +
  162. '</div>';
  163.  
  164. // http://leafletjs.com/reference.html#popup
  165. marker.bindPopup(popupContent,{
  166. closeButton: false,
  167. minWidth: 500
  168. });
  169. });
  170.  
  171. // Add features to the map
  172. map.markerLayer.setGeoJSON(geoJson);
  173.  
  174. function clickButton() {
  175. var coorx = document.getElementById("coords-x").value
  176. var coory = document.getElementById("coords-y").value
  177. L.mapbox.markerLayer({
  178. // this feature is in the GeoJSON format: see geojson.org
  179. // for the full specification
  180. type: 'Feature',
  181. geometry: {
  182. type: 'Point',
  183. // coordinates here are in longitude, latitude order because
  184. // x, y is the standard for GeoJSON and many formats
  185. coordinates: [coorx, coory]
  186. },
  187. properties: {
  188. title: 'A Single Marker',
  189. description: 'Just one of me',
  190. // one can customize markers by adding simplestyle properties
  191. // http://mapbox.com/developers/simplestyle/
  192. 'marker-size': 'large',
  193. 'marker-color': '#f0a'
  194. }
  195. }).addTo(map);
  196. }
  197.  
  198. </script>
  199. </body>
  200. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement