Jump to content

Barand

Moderators
  • Posts

    24,566
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. The attached php files in reply #5 do exactly what you said you want to do - retrieve from db and add map markers via json data.
  2. In your original code you had How did you know what the variables were?
  3. At what point is $obj->isConnected converted to a string?
  4. I guess you need to give it over 2 seconds of actual work to do
  5. json_decode
  6. You didn't look at the code samples in that thread then?
  7. ->setCellValue('F'.$i,$row['prod_sell_override']>0 ? $row['prod_sell_override'] : number_format($row['prod_trade']*100/70), 2) ?
  8. You would lessen the load by putting an index on the user_id column.
  9. Have you tried number_format()?
  10. or $data = file('hansford.txt',FILE_IGNORE_NEW_LINES); natsort($data); foreach ($data as $line) { echo "$line<br>"; } gives #1A - Kessenich #1B - Adams #8 - Johnson #50 - Smith #100 - Sanders
  11. see https://developers.google.com/maps/documentation/javascript/markers and also this topic https://forums.phpfreaks.com/topic/302364-need-help-to-clear-concept-of-google-maps-integration-in-php/?do=findComment&comment=1538471
  12. Your code has quotes missing. Notice the color of the text in the code box above?
  13. Use code tags.
  14. Does it work if you link to a local jquery.js file instead of the google one?
  15. You might use PHP to get the lat/long data via AJAX but communication with maps api would use javascript. https://developers.google.com/maps/documentation/javascript/examples/polyline-simple
  16. Are any of the jQuery calls functioning?
  17. Possibly, it is a neat solution for those who understand the function. Another option may be to organize your query so you can use array_slice().
  18. or simply $clients[] = [ 'name' => $source['name'], 'guid' = $source['guid'] ]; [EDIT] Requinix's turn to beat me to the post
  19. Check the browser console to see if the AJAX calls are behaving
  20. That would be because the query failed // get the google maps key $sql = "SELECT gm_key , ROUND(home_lat,2) , ROUND(home_long,2) FROM mydb.google_map_key"; $res = $db->query($sql); list($gmkey, $home_lat, $home_lng) = $res->fetch_row(); As the comment says, that query fetches my personal Google API key from a database (plus the starting map coordinates for the application. I suggest you provide those three values as hard-coded values for now to get it working. Remove the above code and replace with $home_lat = 27.60; $home_lng = 77.06; $gmkey = "<your api key goes here>"; I did some more testing today. "route_2" works only if the places on the route are on a straight route IE for A - B - C - D If you go off the line as in A - B D | | \ | C then it give the time for AD as less than the time AC. So the code needs changing so, instead of calculating AB, AC, AD as it does now, it calculates AB, BC, CD and accumulates the times. Revised route2 attached. routes_2.php
  21. I haven't used the Google Distance Matrix API before so this was a learning exercise for me. Here's a small application: route_1.pgp - main page with map display route_2.php - responds to AJAX calls to retrieve data route.sql.txt - SQL script file to create database (Note mins and distances are set to zero in the route_definition table) When you load route_1, the routes are listed. Clicking on a route fetches the route definition from the database, submits a request to the google api to get the times and distances and updates the route records in the table. The distances and times are then listed on the screen and the stops are displayed on the map. I hope this helps to get you going. routes.sql.txt routes_1.php routes_2.php
  22. Consult the manual http://php.net/manual/en/migration70.new-features.php
  23. https://developers.google.com/maps/documentation/distance-matrix/start
  24. It looks like you have a lot of duplication of data. Every time you add a bus, you add the stops also. A better approach would be to define the route first. Route definition Stop +-----------+-----------+-----------+--------+ +----------+-----------------------+----------+-----------+ | route_id | sequence | stop_id | mins | | stop_id | stop name | Lat | Long | +-----------+-----------+-----------+--------+ +----------+-----------------------+----------+-----------+ | DA | 1 | 102 | 0 | | 101 | Agra | 27.16945 | 78.01194 | | DA | 2 | 103 | 10 | | 102 | Dehli | 28.60357 | 77.26217 | | DA | 3 | 104 | 190 | | 103 | Noida | etc | | DA | 4 | 101 | 250 | | 104 | Vrindavan | etc | +-----------+-----------+-----------+--------+ +----------+-----------------------+----------+-----------+ Now you can add the timetabled journeys to run on each route Timetabled journey +----------+-------------+----------+ | jny_id | route_id | depart | +----------+-------------+----------+ | 450 | DA | 7:50 | | 451 | DA | 9:50 | Intermediate stop times are then calculated from the route definition. You can take it further if you have a table to allocate the "bus working" defining the sets of journeys scheduled for a bus. This enables you to produce service timetable as well as vehicle timetables. To show on a map first create a map object. For each stop, create a LatLng object using the stop's latitude and longitude values add marker object to map object using the LatLng object [EDIT] Note that the above would be done in Javascript. You would use PHP to retrieve the data required and pass it to the client via an AJAX request.
  25. The input password will not match that in the user table, so your selection criteria should just be where the username matches. Then verify the retrieved password hash.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.