0

On a GoogleMap I am drawing a polyline to show a route. The lat/long-data is requested via Google Directions API and I receive correct data, usually for two different cities, from which I extract the lat/long-values and add it to an Polyoptions-object, which is added to the Polyline of the Map. Whatever the route is long, how much positions/latLng are available, the route never has more than around 8 straight lines. I have read a lot of stuff, and I can be sure, that the route is created correctly, I can even delete one to create another one. I have also tried "geodesic()" with true an false. No change.

Can anybody tell how I can get out of this?

Some code snippet

polylineOptions = new PolylineOptions();
                foreach (var position in routeCoordinates)
                {
                    polylineOptions.Add(new LatLng(position.Latitude, position.Longitude));
                }
gMap.AddPolyline(polylineOptions);

Added on Sept 09, 2016 I started by using the points for the legs-steps, lots of points but wrong route, so I finally used only the final overview for the route this way

    if (createRouteStep == true && prop.Equals("overview_polyline"))
    {
        i++;
        line = getPropAndValue(lines[i]);
        prop = getProp(line);
        propValue = getPropValue(line);
        string point = propValue.Replace(com, space).Trim();//= "yhoyHg~ol@nvgBgbjAbcbByxlDr_iArqG"; 
        startRS = new RouteStep();
        startRS.RouteID = routeCounter;
        startRS.StepPoints = point;
        sql.insertRouteStep(startRS);
        i++;
    }

The code is stored in an sqlite database, from which is later retrieved and decoded. Decoding works correct, I have tried a sample (points-result in the comment above) from the mentioned Google-test-site for this purpose and the route was the same as on the site. The points from my own request for the route have the correct direction, but don't follow any road or reach the destination at all.

macrene
  • 198
  • 1
  • 8
  • It is unclear what you are asking, is this the problem you are having: http://stackoverflow.com/questions/37189634/api-google-maps-doesnt-return-enough-of-step/37191234#37191234 – SushiHangover Aug 26 '16 at 16:46
  • Thx, my problem is kind of that in the link. So, do I HAVE to use the decoded points instead of the also delivered positions, which I am using the position-lat/long-data right now?! – macrene Aug 26 '16 at 17:01
  • Yes, if you want the polylines to follow the roadway you have to use the decoded points **within each** location. – SushiHangover Aug 26 '16 at 17:51
  • I've started working recoding. Thanks a lot, your hints helped me out!!! Why is that not obviously documented. Everything I found about route, did not mention this at all. – macrene Aug 26 '16 at 19:47
  • It helps a lot while learning to go through the Google supplied examples, they might be in Java but it usually translates easily to `Xamarin.Android` : https://developers.google.com/maps/documentation/android-api/ – SushiHangover Aug 26 '16 at 19:59
  • I have tried the mentioned code sample "GooglePoints.cs". It decodes Latitude/longitude, BUT the route is always wrong. I have tried it with polyline, what leads partially to very strange results. e.g. Dortmund -Frankfurt leads over Great Britain and the Mediterrian Sea, and doesn't follow the roads also, while the overview_polyline stays between the cities but neither follow roads nor reaches it the destination city... – macrene Aug 30 '16 at 09:56
  • Try your route in Google's PolyLine Utility: https://developers.google.com/maps/documentation/utilities/polylineutility – SushiHangover Aug 30 '16 at 14:18
  • The route data from Polyline Utility works, but using mine is still absolutely wrong. In which order are the points organized? From start to destination or vice versa? I have tried both, without improvement at all! Really strange. Or have all encoded points to be concatted to one string? – macrene Sep 02 '16 at 21:40
  • Post some code in your question that you are using for your poly lines – SushiHangover Sep 02 '16 at 21:59

0 Answers0