Advertisement
Guest User

Untitled

a guest
Nov 25th, 2016
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. {"type":"Point","coordinates":[40.704719543457,-74.0092620849609]}
  2. {"type":"Point","coordinates":[40.7466468811035,-73.9939117431641]}
  3. {"type":"Point","coordinates":[40.7362442016602,-73.9847412109375]}
  4. {"type":"Point","coordinates":[40.7501983642578,-73.9909286499023]}
  5. {"type":"Point","coordinates":[40.7240562438965,-74.0096588134766]}
  6.  
  7. var json = {
  8. "type": "Point",
  9. "coordinates": [
  10. [40.7666969299316, -73.9906158447266],
  11. [40.6885147094727, -73.9647598266602],
  12. [40.7145042419434, -74.0056304931641],
  13. [40.704719543457, -74.0092620849609],
  14. [40.7271041870117, -74.0029678344727]
  15. ]
  16. }
  17.  
  18. var cods = json.coordinates;
  19. for (i = 0; i < cods.length; i++) {
  20.  
  21. latlng = new google.maps.LatLng(cods[i][0], cods[i][1]);
  22. var marker = new google.maps.Marker({
  23. position: latlng,
  24. map: map,
  25. title: 'test'
  26. });
  27.  
  28. }
  29.  
  30. <?php
  31.  
  32. $connect = pg_connect("host=127.0.0.1 dbname=d106 user=b16 password=cccC") or die("Could not connect: ");
  33. $result = pg_query($connect,"SELECT distinct thestartgeom FROM bike");
  34. if (!$result)
  35. {
  36. echo "no results ";
  37. }
  38.  
  39. while($row = pg_fetch_array($result))
  40. {
  41.  
  42. $coor = $row['thestartgeom'];
  43.  
  44. }
  45.  
  46. pg_close($connect);
  47. ?>
  48. <html>
  49. <head>
  50. <title>Simple Map</title>
  51. <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
  52. <meta charset="utf-8">
  53. <style>
  54. html, body, #map-canvas {
  55. margin: 0;
  56. padding: 0;
  57. height: 100%;
  58. }
  59. </style>
  60. <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSy">
  61. </script>
  62. <script>
  63.  
  64.  
  65.  
  66.  
  67. var map;
  68.  
  69.  
  70. function initialize() {
  71. var mapOptions = {
  72. zoom: 12,
  73. center: new google.maps.LatLng(40.730610, -73.935242),
  74. mapTypeId: google.maps.MapTypeId.ROADMAP
  75. };
  76. map = new google.maps.Map(document.getElementById('map-canvas'),
  77. mapOptions);
  78.  
  79.  
  80. var latlng = $json.coordinates; // here i am attempting to call the php variable with the query
  81. for (i = 0; i < latlng.length; i++) {
  82.  
  83. latlng = new google.maps.LatLng(llatlng[i][0], latlng[i][1]);
  84. var marker = new google.maps.Marker({
  85. position: latlng,
  86. map: map,
  87. title: 'test'
  88. });
  89.  
  90. }
  91. }
  92. google.maps.event.addDomListener(window, 'load', initialize);
  93. </script>
  94. </head>
  95. <body>
  96. <div> <!-- ommiting this div will show the map -->
  97. <div id="map-canvas"></div>
  98. </div>
  99. </body>
  100. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement