Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Path line between start and end points goes off map component. #1

Open
DriiGY opened this issue Jan 9, 2023 · 0 comments
Open

Path line between start and end points goes off map component. #1

DriiGY opened this issue Jan 9, 2023 · 0 comments
Labels
bug Something isn't working invalid This doesn't seem right

Comments

@DriiGY
Copy link
Owner

DriiGY commented Jan 9, 2023

After the two points (start and end) are chosen and consequently the path between them, this path if these are not visible within the map component the line goes off the map component and into the rest of the screen. ex:

aaaaaaaaa

The map was created in the home.kv:

Map:         
     id: main_map

And the points and line are created in:

 def points_line(self, *args):
        if self.my_pin and self.dest_pin:
            #print(self.my_pin.lat)
            #print(self.my_pin.lon)
            self.start_lon = self.my_pin.lon
            self.start_lat = self.my_pin.lat

            self.end_lon = self.dest_pin.lon
            self.end_lat = self.dest_pin.lat
            self.body = {"coordinates":[[self.start_lon, self.start_lat],[self.end_lon, self.end_lat]]}
            self.res1 = self.openrouteservice_request(self.body)

            for i in range(0, len(self.res1)-1, 2):
                # print('lat= ' + self.res1[i])
                # print('lon= ' + self.res1[i+1])

                self.points_lat = self.res1[i]
                self.points_lon = self.res1[i+1]

                self.points_pop = MapMarkerPopup(lat=self.points_lat, lon=self.points_lon, source='assets/imgs/waypoints.png')
                self.route_points.append(self.points_pop)
                #print(type(self.points_pop))
                self.ids.main_map.add_widget(self.points_pop)

            with self.canvas:
                Color(0.5, 0, 0 ,1)
                for j in range(0, len(self.route_points)-1, 1):
                    self.lines = Line(points=(self.route_points[j].pos[0],self.route_points[j].pos[1], self.route_points[j+1].pos[0],self.route_points[j+1].pos[1] ), width=3)
                    self.list_of_lines.append(self.lines)

            Clock.schedule_interval(self.update_route_lines, 1/50)

def update_route_lines(self, *args):
        for j in range(1, len(self.route_points), 1):
            self.list_of_lines[j-1].points = [self.route_points[j-1].pos[0],self.route_points[j-1].pos[1], self.route_points[j].pos[0], self.route_points[j].pos[1]]

@DriiGY DriiGY added bug Something isn't working invalid This doesn't seem right labels Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

1 participant