judero01col / GMap.NET

GMap.NET Windows Forms & Presentation is an excellent open source, powerful, free and cross-platform .NET control. Allows the use of routing, geocoding, directions and maps from Google, Yahoo!, Bing, OpenStreetMap, ArcGIS, Pergo, SigPac, Yendux, Mapy.cz, Maps.lt, iKarte.lv, NearMap, HereMap, CloudMade, WikiMapia, MapQuest and many more.
Other
466 stars 204 forks source link

GMapRoute not updated to current zoom level after zooming in or out #213

Open CodeSleeker opened 3 months ago

CodeSleeker commented 3 months ago

Hi I need help. I created a marker after every click in GMapControl and automatically created a routes between the markers. But when I zoomed in or out and then click the map again the routes is not in the proper placement but the marker is correctly place. Please can anyone help me solve this issue.

aklegend commented 2 months ago

I want to create something like this to create routes Can you share your code?

CodeSleeker commented 2 months ago

@aklegend you can subscribe to mousedown or mouseup event then from there you can get the localpoint position and convert it to LatLng. something like this

private void GMapControl_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { var point = e.GetPosition(GMapControl); var latlng = GMapControl.FromLocalToLatLng((int)point.X, (int)point.Y); var points = new List{ previousLatLng, latlng}; var routes = new GMapRoute(points) { Shape = new System.Windows.Shapes.Path { Stroke = Brushes.Yellow, StrokeThickness = 3 }, Tag = "routes" }; gMapControl.Markers.Add(routes); previousLatLng = latlng; }