Google Map Kit, draw polylines for walk like google map ios

十年热恋 提交于 2020-01-05 02:52:05

问题


I wants to draw polyline for walk like google map app in ios using google maps ios sdk. For more clear understanding i am uploading image that is from google map app(ios.)


回答1:


Are you asking how to achieve the dotted polyline effect? If so, I don't believe that is supported in the SDK.

You can manually create a similar effect with GMSCircles.

    for(int x = 0; x < [self.path count]; x++)
    {
        CLLocationCoordinate2D coord = [self.path coordinateAtIndex:x];

        //draw circle coord
        GMSCircle *circle = [GMSCircle circleWithPosition:coord radius:20];
        circle.fillColor = [UIColor blueColor];
        circle.strokeColor = [UIColor blackColor];
        circle.strokeWidth = 2;

        circle.map = mapView;
    }

For this to really look like the original example you will probably need to add additional points onto the line in order for the circles to be evenly spaced out. For that you could do something like this.

    for(all the points in the path)
    {
        if(the distance from pointA to pointB is > some distance)
        {
            centerPtr = center point of pointA and pointB
            insert centerPt in path
        }
    }

You can turn this into a simple recursive function that should give you something similar to what you are looking for.



来源:https://stackoverflow.com/questions/27540568/google-map-kit-draw-polylines-for-walk-like-google-map-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!