Geometriefunktion (CONVOLUTION) mit Javascript oder jquery
Ich versuche dies 3 Monate lang zu tun - ich muss ein Polygon durch Routenrichtung wie hier erstellen:
also so schreibe ich das:
directionService.route(request, function(result, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsRenderer.setDirections(result);
var r = [];
var z = 0.5;
var bla = result.routes[0].overview_path;
for(var i=0 in result.routes[0].overview_path) {
r.push(new google.maps.LatLng(bla[i].lat()+z, bla[i].lng()-z));
}
bla.reverse();
for(var x=0 in bla) {
r.push(new google.maps.LatLng(bla[x].lat()-z, bla[x].lng()+z));
}
var prva = new google.maps.Polyline({
path: result.routes[0].overview_path,
strokeColor: "#00000",
strokeOpacity: 1.0,
strokeWeight: 2
});
prva.setMap(map);
druga = new google.maps.Polygon({
paths: r,
strokeColor: "#FF0000",
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: "#FF0000",
fillOpacity: 0.35
});
druga.setMap(map);
} else {
alert("Directions query failed: " + status);
}
});
aber in einigen Fällen ist gut in einigen Fällen nicht, so dass mein Code dies erzeugt:
Schlechter Fall:
GUTER Fall:
Also, wie kann ich dieses Problem lösen, um ein schönes Polygon durch Routenrichtung zu erhalten? Hat jemand eine Idee?
So kann ich das in meinen Code implementieren:
CONVOLUTION-ALGORITHMUS
Gibt es eine Lösung für mein Problem?
Gibt es einen anderen Weg als diesen, um das zu schaffen, was ich brauche?