php and javascript help with Google maps v3. How to put a dot between vertices on a polyline?.
<!DOCTYPE html> <html> <head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no"> <meta charset="utf-8"> <title>Simple Polylines</title> <style> html, body, #map-canvas { height: 80%; margin: 0px; padding: 0px } </style> <script src=" https://maps.googleapis.com/maps/api/js?v=3.exp "></script> <script> function initialize() { var mapOptions = { zoom: 19, center: new google.maps.LatLng(-33.879306,18.634443), mapTypeId: google.maps.MapTypeId.TERRAIN }; var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); var flightPlanCoordinates = [ <?php $connection = mysqli_connect("localhost","root","","csv_db"); mysqli_select_db($connection,"csv_db"); //Assuming route that lat and long coordinates are in multiple records and not in a array within a single record //Loop through all records and echo out the positions $query = mysqli_query($connection,"SELECT `mLatitude`, `mLongitude`,`mSpeed` FROM `barn`"); while($row = mysqli_fetch_assoc($query)){ $lat = $row['mLatitude']; $lon = $row['mLongitude']; $speed = $row['mSpeed']; if ($lat == "" ){ $lat = ""; } /*if ($speed == 0){ echo'<script type="text/javascript"> path: flightPlanCoordinates, geodesic: true, strokeColor: "#0000FF", strokeOpacity: 1.0, strokeWeight: 2 })'; echo '</script>' ; }*/ echo 'new google.maps.LatLng('.$lat.', '.$lon.'),'; } $query = mysqli_query($connection,"SELECT `mLatitude`, `mLongitude` FROM `route2`"); $row = mysqli_fetch_assoc($query); $lat2 = $row['mLatitude']; $lon2 = $row['mLongitude']; //echo users ending position echo 'new google.maps.LatLng('.$lat2.', '.$lon2.')'; ?> ]; var flightPath = new google.maps.Polyline({ path: flightPlanCoordinates, geodesic: true, strokeColor: '#FF0000', strokeOpacity: 1.0, strokeWeight: 3 }); //flightPath.setMap(map); //NOW THE PROBLEM COMES HERE for ( var i = 0; i < flightPath.getPath().getLength(); i++ ) { var marker = new google.maps.Marker( { icon : { url : " https://maps.gstatic.com/intl/en_us/mapfiles/markers2/measle_blue.png ", size : new google.maps.Size( 7, 7 ), anchor : new google.maps.Point( 4, 4 ) }, title : flightPath.getPath().getAt( i ), position : flightPath.getPath().getAt( i ), map : map } ); } flightPath.setMap(map); map.setCenter( new google.maps.LatLng( response[ centerIndex ].Lat, response[ centerIndex ].Long ) ); flightPath.setMap( map ); } google.maps.event.addDomListener(window, 'load', initialize); </script> </head> <body> <div id="map-canvas"></div> </body> </html>
@e.mccormick
@dumbsearch2 does PHP and JS.
what?
I don't do anything with those languages, but he does. If he gets on, the at tag should bring him here.
Join our real-time social learning platform and learn together with your friends!