开发者

mkmapview refresh mapview

im using mkmapview to show route between current location and a coordinate. im using polyline to show the route. i have added annotation to start and destination. im using the following api to get the in between coordinates.

http://routes.cloudmade.com/8ee2a50541944fb9bcedded5165f09d9/api/0.3/51.22545,4.40730,[51.22,4.41,51.2,4.41],51.23,4.42/car.js

now if i change the coordinates the already existing route also is visible. how do i remove the existing rou开发者_如何学Cte and add a new route? thanks in advance.


Unless I'm missing something in your question, if you already have the app calculating and displaying an MKPolyline then all you need to do is remove the old one and add the new one. Your code would look something like

// generating new data, do this however you like
MKPolyline *routeLine = [self generateNewRoutLine];
MyPinAnnotation *startPin = [self generateNewStartPin];
MyPinAnnotation *endPin = [self generateNewEndPin];

// removing old overlays and adding new
[myMapView removeOverlays:myMapView.overlays]; // removes all overlays
[myMapView removeAnnotations:myMapView.annotations]; // removes all pins
[myMapView addOverlay:routeLine];
[myMapView addAnnotations:[NSArray arrayWithObjects:startPin, endPin, nil]];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜