Advertisement
Guest User

Draggable Marker

a guest
Feb 22nd, 2013
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.34 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html>
  3. <head>
  4. <script type="text/javascript" charset="UTF-8" src="http://api.maps.nokia.com/2.2.0/jsl.js?routing=auto"></script>
  5.     <title>Random Marker</title>
  6. </head>
  7. <body>
  8.  
  9. <div id="button" style="top:0%; width:100%; height:10%; position: absolute;"><input type="button" onclick="moveRandomly()" value="Press Me" /></div>
  10. <div id="mapContainer" style="top:10%; width:100%; height:70%; position: absolute;"></div>
  11.  
  12. <script type="text/javascript">
  13. /////////////////////////////////////////////////////////////////////////////////////
  14. // Don't forget to set your API credentials
  15. //
  16. // Replace with your appId and token which you can obtain when you
  17. // register on http://api.developer.nokia.com/
  18. //
  19.             nokia.Settings.set( "appId", "YOUR APP ID GOES HERE");
  20.             nokia.Settings.set( "authenticationToken", "YOUR AUTHENTICATION TOKEN GOES HERE");
  21. //         
  22. /////////////////////////////////////////////////////////////////////////////////////
  23.  
  24. //initialize a new map
  25. var display = new nokia.maps.map.Display(document.getElementById("mapContainer"),
  26.                      {     "components": [ 
  27.                                      new nokia.maps.map.component.ZoomBar(),                
  28.                                      new nokia.maps.map.component.Behavior(),                
  29.                                      new nokia.maps.map.component.TypeSelector()],    
  30.                                      "zoomLevel": 13,
  31.                                      "center" : [52.500556, 13.398889] });
  32.  
  33. // Place this anywhere in the world.
  34. var draggableMarker = new nokia.maps.map.StandardMarker([52.500556, 13.398889],
  35. {  
  36. text:  "X",  
  37. brush: {color: '#FF0000'} ,                
  38. draggable: true,                    
  39. });  
  40. // Add the marker to the map.
  41.  
  42. display.objects.add(draggableMarker);
  43.  
  44. function moveRandomly(){
  45.                 // This function will move a marker around the currently visible display.
  46.         var viewPort = display.getViewBounds();
  47.          var coord = new nokia.maps.geo.Coordinate (viewPort.topLeft.latitude  - Math.random()*viewPort.getHeight(),
  48.           viewPort.topLeft.longitude + Math.random()*viewPort.getWidth()
  49.          );
  50.          draggableMarker.set("coordinate", coord);
  51. }
  52.  
  53. </script>
  54. </body>
  55. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement