Comments (4)
Hi @jaska120 ,
Please can you show how you making the call ?
The isLocationOnEdge method only available for Directions API.
Here how this method to be invoked within this package:
$response = \GoogleMaps::load('directions')
->setParam([
'origin' => 'place_id:ChIJ685WIFYViEgRHlHvBbiD5nE',
'destination' => 'place_id:ChIJA01I-8YVhkgRGJb0fW4UX7Y',
])
->isLocationOnEdge(55.86483,-4.25161);
dd( $response ); // true
Regards,
Alexander
from geometry-library.
I am making the call to database where are user previously inserted encoded polylines and point is user defined point to which the query is made against.
$distance = 1000; //meters
$startpoint = array('lat' => 61.487002, 'lng' => 23.790636);
$endpoint = array('lat' => 60.215399, 'lng' => 24.943364);
while($row = $result->fetch_assoc()) {
$encoded = $row["encodedpolyline"];
$polyline = \GeometryLibrary\PolyUtil::decode($encoded);
$startboolean = \GeometryLibrary\PolyUtil::isLocationOnEdge($startpoint,$polyline,$distance);
$endboolean = \GeometryLibrary\PolyUtil::isLocationOnEdge($endpoint,$polyline,$distance);
if ($startboolean and $endboolean) {
//var_dump($encoded);
//var_dump($startboolean);
//var_dump($endboolean);
$data[] = $row;
}
}
$data array is being JSON encoded and sent to client via Ajax call and it returns correctly except the error occurs with the last polyline. In this example I have provided $startpoint and $endpoint arrays hardcoded but those are the coordinates with which user would face error.
Please find attached txt document for encoded polylines SQL queried from $row["encodedpolyline"]. The problem occurs only with the last polyline and the functions works if I delete that from database so I guess it has something do with the format of encoding.
example_encoded_polylines.txt
from geometry-library.
Hi Alexander,
My bad, there was still a problem with escaping backslashes and your code is working normally.
Thanks,
Jaska
from geometry-library.
Hi @jaska120 ,
Thank you for your update, glad to hear that issue has been resolved.
Regards,
Alexander
from geometry-library.
Related Issues (12)
- Update HOT 1
- Issue with PolyUtil::distanceToLine function
- PHP 7.4 Depreciated Syntax HOT 1
- tolerance in meters or degrees HOT 1
- Errors with isLocationOnPath HOT 1
- Intersection of two direction given start points and bearings HOT 1
- Call the function isLocationOnEdge with parameter $ geodesic = false HOT 1
- How do I include into a php file? HOT 1
- Perpendicular of a line in PHP HOT 1
- Call to undefined method GeometryLibrary\\PolyUtil::distanceToLine() HOT 3
- isLocationOnPath issue, HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from geometry-library.