Advertisement
Guest User

Untitled

a guest
May 6th, 2016
538
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.76 KB | None | 0 0
  1. <html>
  2. <head>
  3. <link href="location.css" rel="stylesheet" type="text/css" media="screen">
  4.  
  5. <style type="text/css">
  6. html { height: 100% }
  7. body { height: 100%; margin: 0; padding: 0 }
  8. #map_canvas { height: 100vh}
  9. </style>
  10. <script type="text/javascript"
  11. src=
  12. "http://maps.googleapis.com/maps/api/js?key=AIzaSyB1tbIAqN0XqcgTR1-FxYoVTVq6Is6lD98&libraries=places">
  13. </script>
  14. <?php $servername = "localhost";
  15. $username = "root";
  16. $password = "";
  17. $dbname = "location";
  18.  
  19. // Create connection
  20. $conn = new mysqli($servername, $username, $password, $dbname);
  21. // Check connection
  22. if ($conn->connect_error) {
  23. die("Connection failed: " . $conn->connect_error);
  24. }
  25.  
  26. $sql = "SELECT CellName,Longitude,Latitude FROM locationdata";
  27. $result = $conn->query($sql);
  28. if ($result->num_rows > 0) {
  29.  
  30. // output data of each row
  31. $table_data;
  32. $arrayindex=0;
  33. while($row = $result->fetch_assoc()) {
  34.  
  35.  
  36. $table_data[$arrayindex][0]=$row["CellName"];
  37. $table_data[$arrayindex][1]=$row["Longitude"];
  38. $table_data[$arrayindex][2]=$row["Latitude"];
  39. $arrayindex++;
  40. }
  41. //echo $table_data[0][0];
  42.  
  43. } else {
  44. echo "0 results";
  45. }
  46. $conn->close();
  47.  
  48. ?>
  49.  
  50. <script type="text/javascript">
  51. var locations = <?php echo json_encode( $table_data ) ?>;
  52. var map
  53. function initialize() {
  54.  
  55. var myOptions = {
  56. center: new google.maps.LatLng(7.9343623,80.2343398),
  57. zoom: 8,
  58. mapTypeId: google.maps.MapTypeId.ROADMAP
  59.  
  60. };
  61.  
  62. var map = new google.maps.Map(document.getElementById("default"),
  63. myOptions);
  64.  
  65. setMarkers(map,locations)
  66.  
  67. }
  68.  
  69. function setMarkers(map,locations){
  70.  
  71. var marker, i
  72.  
  73. for (i = 0; i < locations.length; i++)
  74. {
  75.  
  76. var cellname = locations[i][0]
  77. var longi = locations[i][1]
  78. var lat = locations[i][2]
  79. //var add = locations[i][3]
  80.  
  81. latlngset = new google.maps.LatLng(lat, longi);
  82.  
  83. var marker = new google.maps.Marker({
  84. map: map, title: cellname , position: latlngset
  85. });
  86. map.setCenter(marker.getPosition())
  87.  
  88.  
  89. var content = "cell name: " + cellname
  90.  
  91. var infowindow = new google.maps.InfoWindow()
  92.  
  93. google.maps.event.addListener(marker,'click', (function(marker,content,infowindow){
  94. return function() {
  95. infowindow.setContent(content);
  96. infowindow.open(map,marker);
  97. };
  98. })(marker,content,infowindow));
  99.  
  100. }
  101. }
  102.  
  103. </script>
  104.  
  105.  
  106. </head>
  107. <body onLoad="initialize()">
  108. <div id="header">
  109. <form id="searchForm">
  110. <input type="text" id="searchId"/>
  111. <script>// Create the search box and link it to the UI element.
  112. var input = document.getElementById('searchId');
  113. alert(input);
  114. var searchBox = new google.maps.places.SearchBox(input);
  115. map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);
  116.  
  117. // Bias the SearchBox results towards current map's viewport.
  118. map.addListener('bounds_changed', function() {
  119. searchBox.setBounds(map.getBounds());
  120. });
  121.  
  122. var places = searchBox.getPlaces();
  123. var bounds = new google.maps.LatLngBounds();
  124. places.forEach(function(place) {
  125. var icon = {
  126. url: place.icon,
  127. size: new google.maps.Size(71, 71),
  128. origin: new google.maps.Point(0, 0),
  129. anchor: new google.maps.Point(17, 34),
  130. scaledSize: new google.maps.Size(25, 25)
  131. }});</script>
  132. <button>Go</button>
  133. </form>
  134. <ul id="menubar">
  135. <li> <a href=" 2GLocation.html"><button type="button" class="btn btn-hot text-capitalize btn-xs">3G</a></button></li>
  136. <li> <a href=" location.php"><button>3G</button></a></li>
  137. </ul>
  138. <img id ="searchBtn" src=""/></div>
  139. <div id="content"><div id="default" style="width:100%; height:100%"></div></div>
  140.  
  141. <script> document.write("locations");
  142.  
  143. </body>
  144. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement