Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {"type":"Point","coordinates":[40.704719543457,-74.0092620849609]}
- {"type":"Point","coordinates":[40.7466468811035,-73.9939117431641]}
- {"type":"Point","coordinates":[40.7362442016602,-73.9847412109375]}
- {"type":"Point","coordinates":[40.7501983642578,-73.9909286499023]}
- {"type":"Point","coordinates":[40.7240562438965,-74.0096588134766]}
- var json = {
- "type": "Point",
- "coordinates": [
- [40.7666969299316, -73.9906158447266],
- [40.6885147094727, -73.9647598266602],
- [40.7145042419434, -74.0056304931641],
- [40.704719543457, -74.0092620849609],
- [40.7271041870117, -74.0029678344727]
- ]
- }
- var cods = json.coordinates;
- for (i = 0; i < cods.length; i++) {
- latlng = new google.maps.LatLng(cods[i][0], cods[i][1]);
- var marker = new google.maps.Marker({
- position: latlng,
- map: map,
- title: 'test'
- });
- }
- <?php
- $connect = pg_connect("host=127.0.0.1 dbname=d106 user=b16 password=cccC") or die("Could not connect: ");
- $result = pg_query($connect,"SELECT distinct thestartgeom FROM bike");
- if (!$result)
- {
- echo "no results ";
- }
- while($row = pg_fetch_array($result))
- {
- $coor = $row['thestartgeom'];
- }
- pg_close($connect);
- ?>
- <html>
- <head>
- <title>Simple Map</title>
- <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
- <meta charset="utf-8">
- <style>
- html, body, #map-canvas {
- margin: 0;
- padding: 0;
- height: 100%;
- }
- </style>
- <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSy">
- </script>
- <script>
- var map;
- function initialize() {
- var mapOptions = {
- zoom: 12,
- center: new google.maps.LatLng(40.730610, -73.935242),
- mapTypeId: google.maps.MapTypeId.ROADMAP
- };
- map = new google.maps.Map(document.getElementById('map-canvas'),
- mapOptions);
- var latlng = $json.coordinates; // here i am attempting to call the php variable with the query
- for (i = 0; i < latlng.length; i++) {
- latlng = new google.maps.LatLng(llatlng[i][0], latlng[i][1]);
- var marker = new google.maps.Marker({
- position: latlng,
- map: map,
- title: 'test'
- });
- }
- }
- google.maps.event.addDomListener(window, 'load', initialize);
- </script>
- </head>
- <body>
- <div> <!-- ommiting this div will show the map -->
- <div id="map-canvas"></div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement