Advertisement
FANMixco

map

Feb 12th, 2014
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 3.83 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.         <meta http-equiv="X-UA-Compatible" content="IE=7; IE=EmulateIE9; IE=10" />
  5.  
  6.         <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
  7.         <title>Test Data</title>
  8.         <meta name="description" content="How to create a basic map"/>
  9.         <meta name="keywords" content="basic,Getting started"/>
  10.  
  11.         <meta name=viewport content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
  12.  
  13.        
  14.         <script charset="UTF-8" src="http://js.cit.api.here.com/se/2.5.3/jsl.js?with=all"></script>
  15.        
  16.         <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
  17.        
  18.         <style type="text/css">
  19.             html {
  20.                 overflow:hidden;
  21.             }
  22.            
  23.             body {
  24.                 margin: 0;
  25.                 padding: 0;
  26.                 overflow: hidden;
  27.                 width: 100%;
  28.                 height: 100%;
  29.                 position: absolute;
  30.             }
  31.            
  32.             #mapContainer {
  33.                 width: 100%;
  34.                 height: 100%;
  35.                 left: 0;
  36.                 top: 0;
  37.                 position: absolute;
  38.             }
  39.            
  40.             #uID
  41.             {
  42.                 z-index: 10;
  43.                 position: relative;
  44.             }
  45.            
  46.         </style>
  47.     </head>
  48.     <body>
  49.     <input type="text" id="uID" PlaceHolder="Ingrese el ID"></input>
  50.         <div id="mapContainer"></div>
  51.         <div id="uiContainer"></div>
  52.         <script type="text/javascript" id="exampleJsSource">
  53.             $(function()
  54.                 {
  55.                 var  testTextBox = $('#uID');
  56.                 var code =null;
  57.                 testTextBox.keypress(function(e)
  58.                 {
  59.                     code= (e.keyCode ? e.keyCode : e.which);
  60.                     if (code == 13)
  61.                         createMarkers(testTextBox.val());
  62.                    
  63.                     e.preventDefault();
  64.                 });
  65.  
  66.  
  67.         /*  Setup authentication app_id and app_code
  68.             *   WARNING: this is a demo-only key
  69.             *   please register for an Evaluation, Base or Commercial key for use in your app.
  70.             *   Just visit http://developer.here.com/get-started for more details. Thank you!
  71.             */
  72.             nokia.Settings.set("app_id", "DemoAppId01082013GAL");
  73.             nokia.Settings.set("app_code", "AJKnXv84fjrb0KIHawS0Tg");
  74.             // Use staging environment (remove the line for production environment)
  75.             nokia.Settings.set("serviceMode", "cit");
  76.  
  77.             // Get the DOM node to which we will append the map
  78.             var mapContainer = document.getElementById("mapContainer");
  79.             // Create a map inside the map container DOM node
  80.            
  81.            
  82.            
  83.             var map = new nokia.maps.map.Display(mapContainer, {
  84.                 // Initial center and zoom level of the map
  85.                 center: [25.841154, -104.176286],
  86.                 zoomLevel: 5.25,
  87.                 // We add the behavior component to allow panning / zooming of the map
  88.                 components:[new nokia.maps.map.component.Behavior()]
  89.             });
  90.  
  91.             /* Create a marker on a specified geo coordinate
  92.              * (in this example we use the map's center as our coordinate)
  93.              */
  94.             var standardMarker = new nokia.maps.map.StandardMarker(map.center);
  95.             // Next we need to add it to the map's object collection so it will be rendered onto the map.
  96.             map.objects.add(standardMarker);
  97.  
  98.             var locations;
  99.             function createMarkers(value)
  100.             {
  101.                 $.ajax({
  102.                     url: "http://thewetzone.pixub.com/web_services/getLocation.php?uid="+value,
  103.                     type: "GET",
  104.                     dataType: "json",
  105.                     success: function(source){
  106.                         locations = source;
  107.                         showInfo();
  108.                     },
  109.                     error: function(dato){
  110.                         alert("ERROR");
  111.                     }
  112.                 });                
  113.             }
  114.            
  115.             function showInfo()
  116.             {
  117.             var markers = [];
  118.  
  119.  
  120.             /* Attach an event listener to the newly created marker
  121.              * to show info bubble on click of the marker
  122.              */
  123.              for (var idx = 0; idx < locations.length; idx++) {
  124.                 loc = locations[idx];
  125.  
  126.                 alert(loc.latitude);
  127.                 alert(loc.longitude);
  128.                
  129.                 /* Create a marker on a specified geo coordinate*/
  130.                 var marker = new nokia.maps.map.StandardMarker([loc.latitute, loc.longitude]);
  131.  
  132.                 // add the standard marker to the map's object collection so it will be rendered onto the map
  133.                 markers.push(marker);
  134.              }
  135.        
  136.             map.objects.addAll(markers);                   
  137.                 }
  138.             });
  139.         </script>
  140.     </body>
  141. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement