Flutter draw route polyline and calculate distance on Google Map.


MorUde Frrr - (Fly Or Not)



Many developer looking same things, how to draw polyline/route on map? So here you are on right place we going to draw route on Google Map.

So first of all, You have to create Flutter project and need to add below dependancy in pubspec.yaml file.

[google_maps_flutter]

We are going to use official Flutter google map plugin. You have to follow all the requirement septs to add google map plugin in the project  and also need to generated google map API KEY.

Well thats enough right now. We are going on coding funda. Let's open your project. Right now you have set it up Google Map API KEY for iOS and Android platform.

I don't want to write details because many tutorials you can find how to integrate Google Map in the Flutter app.

So, Let's start for route on the map.






Here we have declare  _initialCamera to display current visible area of the map.
Two LatLng for draw route line source to destination here,  variable name will be anything you want.




Added marker for source and destination LatLong.





In the build method we have integrated initial Google Map.










Here below is main code that will use to draw the route.

https://maps.googleapis.com/maps/api/directions/json?origin=Lat,Long&&destination=Lat,Long&key=XYZ

By calling above url, you will get steps  and also you will get the distance between source and destination.

Instead of write code here, You can check full code from my GitHub repo. Below is the link, Download and check the code The result will be.







Good Luck!!!


34 comments:

  1. This is a good post. I'm definitely going to look into it.Really very useful tips are provided here.thank you so much.Keep up the good works.

    flutter app

    ReplyDelete
  2. thanks for sharinf wonderful information. guys you can find some more information related to React Native vs Xamarin

    ReplyDelete
  3. Hi just want to know if it is paid to get distance. I mean you really have to enable billing?

    ReplyDelete
    Replies
    1. Nope, you just have to add your cars they won't deduct money. Because we are working on small app and its enough for free plan

      Delete
  4. What a fantastic post! This is so chock full of useful information I can't wait to dig deep and start utilizing the resources you have given me. Your exuberance is refreshing. Lots of good advice here, but I want to plead with anybody planning to build auction software real estate to track business activity. Thanks again for this valuable post.

    ReplyDelete
  5. I found this one eye-catching & elegant blog post. It is very informative for everyone. Very good work! I am Impressed.

    Hire Dedicated Flutter App Developers

    ReplyDelete
  6. Once again you provide several doses of reality which explore the complete explanation of packing and moving companies in Bangalore . This article don't have to be that long. I simply couldn't leave your web site before suggesting that I actually loved the usual info on packing and movers services in Bangalore. I just want to know what is the best way to get real service.

    ReplyDelete
  7. Thank you so much for providing such valuable information. I have never ever gone through such an article and it is a great source of knowledge regarding IT consulting companies in NYC. It has been the best concise guide informing about the real estate listing management software. There have been a lot of good strategies over here and those who are looking to hire for the custom healthcare software development company can easily look at the aspects for an ideal software development company. For readers, if you want More information regarding software development companies then this blog is helpful.

    ReplyDelete
  8. In order to function as a printer, it is very important to download and install a proper driver from 123.hp.com/setup. Type the link 123.hp.com/setup onto the browser & type the correct model number in the search box and download the driver.

    ReplyDelete
  9. Since its launch, RisingMax has been following the principles of building and implementing great ideas, empowering customers' businesses and improving their lives through innovative enterprise solutions. Our team at RisingMax is distinguished by the cross-technology imagination, knowledge and experience we bring to every project we deal with. We understand the importance of nurturing interpersonal relationships.

    ReplyDelete
  10. I’m so glad you enjoyed your Post. Thanks for inspiring me. It is very informative!!

    Fantasy Sports App Development

    ReplyDelete
  11. Mobile app development is a lucrative and in-demand job path. Enroll in an advanced program in Android app development to determine if you're cut out for a future as a mobile app developer. Suffescom Solutions should also be aware of the App Store Optimization procedure, which is critical if you want to be found by consumers looking for apps that are comparable to yours.

    ReplyDelete
  12. This comment has been removed by the author.

    ReplyDelete
  13. Thank you for providing the best information regarding mobile apps. It is very user-friendly and covers every aspect of food delivery app development.  Since technology is evolving especially in terms of the food business. The rise of mobile app development is also achieving new heights. Here the Suffescom solutions provide all sorts of information regarding mobile app development under one roof.

    ReplyDelete
  14. Nice article! Thanks for sharing so much good information on this topic, I have read your whole blog which is very helpful for beginners. Discord Clone App is a platform for Voice-over IP, Instant Messaging, and Digital Distribution. In private chat or as part of a "server", users communicate with voice calls, video calls, text messaging, media, and files.

    ReplyDelete
  15. Dart has many great benefits for developers, as seen in this post. Developers can use it as a compiler or executor to develop robust, fast, and superior apps. Both Google’s products make Flutter and Dart the most dangerous duo. They also support other Google products. Companies and entrepreneurs should hire Flutter developers who are experienced before anyone else. Contact Insync for the premium quality service by the industry expert Flutter Developers in the market.

    ReplyDelete
  16. Thank You for posting this awesome blog. Many people will definitely get benefit from this. This informative post appears to be the help of flutter app development company. Hire flutter App Developers team has the experience and skills to design quality native interfaces for functional & feature-rich apps for your business. Feel free to contact Us.

    ReplyDelete
  17. A solid article on Flutter Development was posted by you. It's incredibly informative and helpful, and I appreciated it. Thank you so much for creating this blog for people looking for information on Flutter programming.
    best it company in punjab

    ReplyDelete
  18. Thanks for sharing this informative article on how to draw polyline/route on map using flutter with useful examples and screenshot. If you have any requirement to Hire Flutter Developers for your project. Please contact us.

    ReplyDelete
  19. I read your article and agree with all of your points and it is quite valuable and relevant.

    NFT Development Company

    ReplyDelete
  20. Your essay is excellent. That greatly aids me in expanding my knowledge.
    Flutter training in surat

    ReplyDelete
  21. The radical evolution in the tech-savvy world revolutionises business histories and the future. Flutter app development is a runaway towards business success, like Uber, eBay, Airbnb, Alibaba, etc. Hence, the demand for flutter app development companies is skyrocketing.

    ReplyDelete
  22. Thanks for sharing this informative article. If you have any requirement to Hire Flutter Developers for your project. Please contact us.

    ReplyDelete
  23. Thanks for sharing this post, you have provided a tutorial on how to draw a polyline on Google Maps using Flutter and calculate the distance between two locations. The post is useful for developers looking to implement location-based features in their Flutter apps. If you want to Hire the Best Flutter App Developers from India, please contact us, and we will be happy to help you.

    ReplyDelete
  24. If you're looking for the best flutter app development company , your search ends here. JPloft Solution provides the best-in-class, feature-rich cross-platform app solutions based on Flutter technology and the latest trends.

    With over a decade of experience in creating mobility solutions, JPloft offers robust and natively compiled experiences for web, mobile, and desktop.

    ReplyDelete
  25. This blog likely provides a tutorial on how to draw a polyline on Google Maps in a Flutter app while calculating distance. It may offer step-by-step instructions and code examples for implementing this feature. A valuable resource for Flutter developers looking to enhance their app with interactive maps and route tracking. If you are looking forward to Hire Kotlin Developers, we will gladly help you.

    ReplyDelete
  26. Thanks for sharing this informative article on Flutter draw route polyline and calculate distance on Google Map. If you want to Hire Flutter Developers for your project. Please visit us.

    ReplyDelete
  27. wow, very good content writing, clear topics are absolutely perfect and give coding examples and flutter types, thanks for sharing this information.

    your interest in flutter development to click hear Flutter Development

    ReplyDelete
  28. Great tutorial on using Flutter to draw polylines on Google Maps! This step-by-step guide really helped me understand how to implement this feature effectively. As someone interested in Flutter development, I'm always on the lookout for informative resources like this.

    For those looking to hire Flutter developer , tutorials like these demonstrate the depth of knowledge and expertise required to create engaging and functional applications. The clarity of explanation in this post speaks volumes about the author's proficiency in Flutter and Dart.

    Keep up the fantastic work! Looking forward to more insightful content like this in the future.

    ReplyDelete
  29. Gratitude for sharing this post. The post is helpful for developers to create an flutter application. If you want to hire flutter developers, reach us, we will be eager to assist you.

    ReplyDelete
  30. Thanks for sharing your Blog. It was really good.

    Flutter App Development Company

    ReplyDelete