Closed omkarkhalipe closed 5 years ago
Please share your project files on github repository.
did you get a chance to check it? It would be great if you could provide a example for isLocationOnEdge()
My private time is limited. Thus, free support is low priority.
I checked the implementation code, and isLocationOnEdge()
always false is correct.
The reason is latLng is not on the polyline.
Finger is bigger than mouse pointer. Thus, even click on polyline, most cases are not on polyline. That's why polyline has margin.
For example, you can click on 1px polyline, but it's really difficult exactly on the 1px width polyline. That's why plugin access +-10px.
Then plugin sends the event with original touched lat/lng, which is not on the polyline.
Basically I am checking if point is on polyline when clicked on polyline
polyline.on(GoogleMapsEvent.POLYLINE_CLICK)
Also I tried to increase width, but same result
` let polyline: Polyline = this.map.addPolylineSync({ points: AIR_PORTS, color: '#AA00FF', width: 40, geodesic: true, clickable: true // clickable = false in default });
polyline.on(GoogleMapsEvent.POLYLINE_CLICK).subscribe((params: any) => {
let position: LatLng = <LatLng>params[0];
alert("test"+ Poly.isLocationOnEdge(position,AIR_PORTS));
console.log("test"+ Poly.isLocationOnEdge(position,AIR_PORTS));
let marker: Marker = this.map.addMarkerSync({ position: position, title: position.toUrlValue(), disableAutoPan: true }); marker.showInfoWindow(); });`
The marker is added correctly on polyline though.
Please check the code how to implement. This plugin is fully open source code. If you can't satisfy implementation, please send a pull request.
Here you are. Code is fully written in JavaScript. https://github.com/mapsplugin/cordova-plugin-googlemaps/blob/master/www/poly.js
Since the code is written in JavaScript, you can understand the code logic.
As you can see, isLocationOnEdge
does not consider polyline.width
because the second argument is path
not polyline
.
Thus, the isLocationOnEdge
returns always false
. This is not a bug.
I prefer the person who do his/her best, not just pushing his/her opinion. At least you should read the code.
I'm submitting a ... (check one with "x")
If you choose 'problem or bug report', please select OS: (check one with "x")
cordova information: (run
$> cordova plugin list
)If you use
@ionic-native/google-maps
, please tell the package.json (only@ionic-native/core
and@ionic-native/google-maps
are fine mostly)Current behavior:
I am trying to check if lat,lon is on polyline but no matter what I do isLocationOnEdge always returns false, even for direction polyline, I able to draw polyline but not able to test if coordinate is on polyline
Expected behavior:
Screen capture or video record:
Related code, data or error log (please format your code or data):