Drawing route on Google Map – MKMapView

Using this post, we will discuss “How to draw a route on google mapview (MKMapView ) ? ”

Step 1 : Import files as listed follows.

Step 1 Google Map

 

Step 2 : Open your view controller header file & import following files.

Step 3 : Open you view controller implementation (.m) file & place following code.

Here is the screenshot of expected Output.

Output Google Map

Click here to grab the sample code.

If you are facing crashes using this sample code, I recommend you to read next post for this.

17 thoughts on “Drawing route on Google Map – MKMapView

  1. Angel

    hi Neon Spark
    Only a question. Do you know how to add RegexKitLite like an api in xcode 5? I have a problem with the function [ stringByMatching: capture];, the app crash in the line and throws the next error:
    [__NSCFString stringByMatching:capture:]: unrecognized selector sent to instance 0x7b5ee70

    you’ll save me if you tell me what is happening!!!

  2. saurabh

    got a linking error when I tried to use it in my app. :(
    However I was able to run sample project.

    Error I got while linking :

    Undefined symbols for architecture i386:
    “_uregex_setText”, referenced from:
    _rkl_clearCacheSlotSetTo in RegexKitLite.o
    _rkl_setCacheSlotToString in RegexKitLite.o
    “_uregex_close”, referenced from:
    _rkl_clearCacheSlotRegex in RegexKitLite.o
    “_u_errorName”, referenced from:
    _rkl_userInfoDictionary in RegexKitLite.o
    _rkl_performRegexOp in RegexKitLite.o
    “_u_strlen”, referenced from:
    _rkl_userInfoDictionary in RegexKitLite.o
    “_uregex_open”, referenced from:
    _rkl_getCachedRegex in RegexKitLite.o
    “_uregex_groupCount”, referenced from:
    _rkl_getCachedRegex in RegexKitLite.o
    “_uregex_find”, referenced from:
    _rkl_search in RegexKitLite.o
    “_uregex_findNext”, referenced from:
    _rkl_search in RegexKitLite.o
    _rkl_replaceAll in RegexKitLite.o
    “_uregex_start”, referenced from:
    _rkl_search in RegexKitLite.o
    _rkl_performRegexOp in RegexKitLite.o
    “_uregex_end”, referenced from:
    _rkl_search in RegexKitLite.o
    _rkl_performRegexOp in RegexKitLite.o
    “_uregex_reset”, referenced from:
    _rkl_replaceAll in RegexKitLite.o
    “_uregex_appendReplacement”, referenced from:
    _rkl_replaceAll in RegexKitLite.o
    “_uregex_appendTail”, referenced from:
    _rkl_replaceAll in RegexKitLite.o
    ld: symbol(s) not found for architecture i386
    collect2: ld returned 1 exit status

  3. saurabh

    Got a linking error when I try to use it in my app :( .
    However I was able to run sample project.

    Error I got while linking in my app

    Undefined symbols for architecture i386:
    “_uregex_setText”, referenced from:
    _rkl_clearCacheSlotSetTo in RegexKitLite.o
    _rkl_setCacheSlotToString in RegexKitLite.o
    “_uregex_close”, referenced from:
    _rkl_clearCacheSlotRegex in RegexKitLite.o
    “_u_errorName”, referenced from:
    _rkl_userInfoDictionary in RegexKitLite.o
    _rkl_performRegexOp in RegexKitLite.o
    “_u_strlen”, referenced from:
    _rkl_userInfoDictionary in RegexKitLite.o
    “_uregex_open”, referenced from:
    _rkl_getCachedRegex in RegexKitLite.o
    “_uregex_groupCount”, referenced from:
    _rkl_getCachedRegex in RegexKitLite.o
    “_uregex_find”, referenced from:
    _rkl_search in RegexKitLite.o
    “_uregex_findNext”, referenced from:
    _rkl_search in RegexKitLite.o
    _rkl_replaceAll in RegexKitLite.o
    “_uregex_start”, referenced from:
    _rkl_search in RegexKitLite.o
    _rkl_performRegexOp in RegexKitLite.o
    “_uregex_end”, referenced from:
    _rkl_search in RegexKitLite.o
    _rkl_performRegexOp in RegexKitLite.o
    “_uregex_reset”, referenced from:
    _rkl_replaceAll in RegexKitLite.o
    “_uregex_appendReplacement”, referenced from:
    _rkl_replaceAll in RegexKitLite.o
    “_uregex_appendTail”, referenced from:
    _rkl_replaceAll in RegexKitLite.o
    ld: symbol(s) not found for architecture i386
    collect2: ld returned 1 exit status

    1. Neon Spark Post author

      Download the sample code placed at the bottom of post.
      Open the sample code.
      Ensure that you have added all necessary frameworks.

      Hope that helps.

      Thanks,
      Spark.

    2. Neon Spark Post author

      go to project – build settings,
      Search for other linker flags,
      add one linker flags as follows.
      -libcucore

      & your app will work like charm !
      Best of luck, due.

      Thanks,
      Spark.

    1. Sagar R. Kothari Post author

      Place* home = [[[Place alloc] init] autorelease];
      home.name = @”Home”;
      home.description = @”Sweet home”;
      home.latitude = 41.029598;
      home.longitude = 28.972985;

      [self.mapview addAnnotation:home];

  4. venkat1988

    Screen Shot 2012-10-26 at 12.22.31 PM

    hi,i created map view with get diredtion button…

    how to find path from current location to destination by clicking get direction button

    1. Sagar R. Kothari Post author

      Hey venkat ! Read this post from beginning. You will notice some latitude & longitude settings for home. Set lat-long of current location into home placemark. Same way set lat-long of your destination. Hope this hint will work for you.

Leave a Reply

Your email address will not be published. Required fields are marked *



*