<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by TRIEN TRAN on Medium]]></title>
        <description><![CDATA[Stories by TRIEN TRAN on Medium]]></description>
        <link>https://medium.com/@trientran?source=rss-9225f36e7503------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*1zhsMx3Fe_VqwTLyd5jb_g.png</url>
            <title>Stories by TRIEN TRAN on Medium</title>
            <link>https://medium.com/@trientran?source=rss-9225f36e7503------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 23:47:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@trientran/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Passing the TensorFlow Developer Exam (2024 updated)]]></title>
            <link>https://medium.com/@trientran/tensorflow-developer-certificate-exam-practice-tests-2024-761ce6e71710?source=rss-9225f36e7503------2</link>
            <guid isPermaLink="false">https://medium.com/p/761ce6e71710</guid>
            <dc:creator><![CDATA[TRIEN TRAN]]></dc:creator>
            <pubDate>Sun, 25 Feb 2024 07:12:30 GMT</pubDate>
            <atom:updated>2024-03-10T04:09:03.832Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HfYuBdwS-aplKQggM4AHRA.png" /></figure><p>Are you interested in obtaining the TensorFlow Developer Certificate? Having successfully passed the exam twice in the last three years, I have a thorough understanding of the exam format and the preparation required. I can guide you to be exam-ready in just two hours.</p><p>My certificate: <a href="https://www.credential.net/f7b087a1-a977-4b84-bdd6-fb7d92eae41b#gs.5ixw48">https://www.credential.net/f7b087a1-a977-4b84-bdd6-fb7d92eae41b#gs.5ixw48</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EyHmuSJDYyUydRvUAMRJ6w.png" /></figure><p>I’ve developed an online course on Udemy, which is also available in an eBook format, to assist candidates like you in efficiently preparing for the certification.</p><p>Full Udemy course (recommended):</p><p><a href="https://www.udemy.com/course/tensorflow-developer-certificate-exam-practice-tests/?referralCode=5BDEEC5D3C9D0BA109F8">https://www.udemy.com/course/tensorflow-developer-certificate-exam-practice-tests/?referralCode=5BDEEC5D3C9D0BA109F8</a></p><p>Ebook:</p><ul><li><a href="https://books2read.com/u/bo9vrR">Available now at your favorite digital store!</a></li><li><a href="https://www.amazon.com.au/TensorFlow-Developer-Certificate-Practice-Tests-ebook/dp/B0CV19NDD1/ref=sr_1_1?dib=eyJ2IjoiMSJ9.mfybt4pIJk2lImtgNMG9uHQohp5Krt_3sq-77uAUj0eeNOndqgUYkl1IRrWGzMPyNx1w2qsZKnI47a-RGXuPT5EqKOVgbst7_YHDb5XmqUk.z0-t_2z4tFu38TWQKwxdeDTNBdAXmsxnpgONiC57yRY&amp;dib_tag=se&amp;keywords=tensorflow+developer+certificate+practice+tests&amp;qid=1708844965&amp;s=amazon-devices&amp;sr=1-1">TensorFlow Developer Certificate Exam Practice Tests 2024 made easy</a></li></ul><h3>What you’ll learn</h3><ul><li>Participants will be thoroughly prepared for the exam with tailored practice tests that closely mimic the format and content of the actual certification exam.</li><li>Upon passing the exam, students will be able to add a digital badge to their LinkedIn profiles and join the TensorFlow Certificate Network.</li><li>Learners will warm up hands-on experience in TensorFlow by completing practice tests and exercises in real-world scenarios.</li><li>Students will regain a deep understanding of TensorFlow fundamentals, including Linear Regression, Image Classification, NLP, and Time Series predictions.</li></ul><h3>Course content</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xKb4zBK2Sy81PFVBNtVdBQ.png" /></figure><h3>Requirements</h3><ul><li>Basic understanding of any programming language (Python preferred).</li><li>It’s beneficial if learners have a foundational knowledge of machine learning principles.</li></ul><h3>Description</h3><p>Welcome to “TensorFlow Developer Certificate Exam Practice Tests 2024 made easy,” your efficient path to mastering TensorFlow and preparing for certification. This course will equip you with the knowledge and practical skills needed for the TensorFlow Developer Certificate Exam in a convenient format.</p><p><strong>What Makes This Course Effective?</strong></p><ul><li><strong>Streamlined Learning</strong>: Ideal for those with busy schedules, our focused content is structured to make the most of your time (in less than 2 hours).</li><li><strong>Hands-On Practice</strong>: Dive into practice tests across key TensorFlow areas like Linear Regression, Image Classification, NLP, and Time Series, crafted to enhance your understanding and proficiency.</li><li><strong>Insider Knowledge</strong>: Gain insights with expert tips that will help you confidently approach the exam.</li><li><strong>Flexible Learning Environment</strong>: Choose your preferred learning tool — Google Colab, Jupyter Notebooks, or PyCharm — to work through the content.</li></ul><p><strong>Why Choose This Course?</strong></p><ul><li><strong>Prepare with Confidence</strong>: Our carefully designed practice tests aim to give you a solid grounding in the exam’s format and content areas.</li><li><strong>Join a Community</strong>: Consider joining the TensorFlow Certificate Network to connect with other professionals upon completion.</li><li><strong>Showcase Your Skills</strong>: Learn how to add a digital badge to your LinkedIn and GitHub profiles to highlight your TensorFlow capabilities.</li></ul><p>Enroll in “TensorFlow Developer Certificate Exam Practice Tests 2024 Made Easy” and start building your practical TensorFlow skills today!</p><h3>Who this course is for:</h3><ul><li>Aspiring or current AI and machine learning professionals aiming to gain TensorFlow certification.</li><li>Individuals with basic programming knowledge and/or a foundational understanding of machine learning concepts.</li><li>Developers and students looking for a comprehensive yet concise preparation for the TensorFlow Developer Certificate Exam.</li><li>Anyone interested in enhancing their TensorFlow skills and adding a recognized credential to their resume or online profiles.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=761ce6e71710" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HOW TO MAKE YOURSELF MORE EASILY UNDERSTOOD BY NON-ENGLISH SPEAKERS]]></title>
            <link>https://medium.com/@trientran/how-to-make-yourself-more-easily-understood-by-non-english-speakers-e6499b70ccc9?source=rss-9225f36e7503------2</link>
            <guid isPermaLink="false">https://medium.com/p/e6499b70ccc9</guid>
            <category><![CDATA[english-language]]></category>
            <category><![CDATA[language]]></category>
            <category><![CDATA[communication-skills]]></category>
            <dc:creator><![CDATA[TRIEN TRAN]]></dc:creator>
            <pubDate>Sun, 09 Jun 2019 05:42:58 GMT</pubDate>
            <atom:updated>2021-10-16T06:53:30.075Z</atom:updated>
            <content:encoded><![CDATA[<h3>HOW TO MAKE YOURSELF MORE EASILY UNDERSTOOD BY NON-NATIVE ENGLISH SPEAKERS</h3><p>English is a global language. It is used widely in business communication in countries across continents where English is not an official language. As a native speaker of English, have you ever encountered any difficulty expressing your messages to those who speak English as a second language? The other way around, I am pretty sure that those non-native English speakers gleaned only the gist of what you said if you spoke in your own American, British, or Australian way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*PvaLPynqPeAJvdtZ.png" /></figure><h3>ARE NATIVE SPEAKERS THE WORST COMMUNICATORS?</h3><p>There was a case where a multinational company suffered huge financial losses due to just one misunderstood word in an email sent from a native English speaker to a colleague in China. It was not because of the Chinese man’s capacity for understanding English, but because he looked up the word in an English-Chinese dictionary and picked the meaning that was not intended by his native English speaking colleague.</p><p>Some native speakers assume that they don’t have to learn another language since they are content with the fact that English has become the world’s language. But you may have read a story about a business meeting with heaps of people from various non-native English speaking nations confidently and fluently communicating in English and they understand each other very well. Then when an Australian or British turns up, nobody could understand him or her.</p><p>There was another story that happened at a 200 personnel French company based in Vietnam. At one stage, the staff had a video conference with an American representative of a business client from the US. In spite of competent English, the French and Vietnamese staff could not understand the American at face value but the gist of his speech. Eventually, they came up with an agreed version of the meeting minutes which might contain some unexpected points.</p><h3>WHY DON’T I UNDERSTAND YOU?</h3><p>Anglophones tend to speak too fast for non-native speakers to keep up with. They also use slang, jokes and particular expressions used within their own culture or community. In contrast, the non-native speakers often talk purposefully without flowery language and use more common limited vocabulary that is easily understood.</p><p>At most tertiary schools in Australia, we not only have international students but also lecturers who come from other countries and territories like China, Vietnam, Hong Kong, etc. The international students from South Korea, Vietnam or China find it much easy to understand one another as well as the Chinese teachers while unable to pick up every word from the locals.</p><h3>HOW DO I REACT IF I DON’T UNDERSTAND WHAT YOU SAID?</h3><p>Many non-Anglophones, especially Asians, would prefer nodding or just smiling as a means of approval or acceptance and avoid ‘losing face’ despite not getting the messages at all. Without the locals’ concerning whether they understand or not, after the meeting, they might ask what the agenda is about or just simply walk away and do nothing.</p><h3>HELPFUL TIPS FOR NATIVE SPEAKERS</h3><p>Here are some common tips for Aussies, Brits, and Americans to communicate effectively with people from the other side of the English world:</p><ol><li><strong><em>Avoid abbreviations.</em></strong> What is ETA? What is ASAP? You know they stand for Estimated Time of Arrival and As Soon As Possible but not all non-native speakers do.</li><li><strong><em>Be concerned about your cultural style.</em></strong> When you respond to a business idea or a proposal by commenting: “that’s interesting”, it might mean it’s ‘rubbish’ to you, but other nationalities might take it as a compliment.</li><li><strong><em>Listen to your own voice and consider it’s speed.</em></strong> Talking too fast or with a lower voice won’t form a good speech as people cannot follow what you say. This could become worse if the meeting is conducted via phone calls or video calls with a poor internet connection. So don’t feel rushed to fill the gap in your speech because your normal speed is probably seen as being fast to others.</li><li><strong><em>The simpler, the better.</em></strong> Simplify your statements with short, clear and direct sentences. Uncommon words and phrases don’t help.</li><li><strong><em>Be receptive and adaptable.</em></strong> It is very important to pay attention to the whole range of varying ways of using English and the different levels of fluency of people from different backgrounds.</li></ol><p>The world is becoming more and more interconnected and interdependent with the trend of globalisation where English is, by default, a crucial language in business, governmental and educational communication. Minding your way of speaking English and being mindful of how non-native speakers understand you play a vital role in bringing success to your multinational/transnational businesses.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e6499b70ccc9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android — working with Google Maps and Directions API]]></title>
            <link>https://medium.com/@trientran/android-working-with-google-maps-and-directions-api-44765433f19?source=rss-9225f36e7503------2</link>
            <guid isPermaLink="false">https://medium.com/p/44765433f19</guid>
            <category><![CDATA[google-directions-api]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[google-maps-api]]></category>
            <dc:creator><![CDATA[TRIEN TRAN]]></dc:creator>
            <pubDate>Fri, 31 May 2019 04:03:07 GMT</pubDate>
            <atom:updated>2019-05-31T04:41:52.474Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Android — working with Google Maps and Directions API</strong></h3><p><strong>Android — working with Google Maps and Directions API</strong></p><p>Imagine that we are required to build an app that includes an area on the map with highlighted routes and annotations and markers like below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hx9iapG2eNo_H5szNrAVfA.png" /></figure><p>As the app design shows, there are 5 bus routes and many bus stops along the way. Also, we are required to add an annotation for every bus stop and appropriate directional arrows for each route. It can be achieved easily by taking advantage of Google Maps SDK to build customized, agile experiences that bring the real world to our users with static maps. The Directions API is utilized in this app to give users the best routes to get from A to Z with high-quality directions.</p><p>The steps involved to build this simple app are as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/1*ar15ERwh-3ptFEWjY_Z4Ow.png" /></figure><p>In this tutorial, we will be using Android Studio 3.4 to create this app using Java language. The sample code package can be downloaded <a href="https://github.com/trientran/android-styled-map">here</a>.</p><h3>1. Create a new project using Android Studio</h3><p>Just follow the New Project wizard to create a new Android project with Google Maps Activity included. By default, min SDK Version is set to 19 and targeted SDK Version is 28.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*hs9b22eMxQYy8Styx18-Ng.png" /></figure><h3>2. Create Google Maps API key</h3><p>Once we are done with creating a new project, Android Studio should have automatically opened google_maps_api.xml (in values folder) that displays details on how to generate a Google Maps API key.</p><p>The easiest way is to copy and paste the provided link to a web browser:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*MiR_qeEOP2tTdd56_KuuWg.png" /></figure><p>Follow the instructions and you will get the key at the last step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*8yeAgwdrk9grptVYFLzSWg.png" /></figure><p>Finally, once you have your key (it starts with “AIza”), replace the “google_maps_key”<br> string in google_maps_api.xml:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*esP4zjD3P08gsinA-NKmPQ.png" /></figure><p>Alternatively, you can go to <a href="https://console.developers.google.com/">https://console.developers.google.com</a> and create a new key for your existing or new project. <strong>Note: there seems to be a bug with Android Studio 3.4 for PC as of May 31, 2019, since the provided package name in this file is exactly the same as SHA-1 certificate fingerprint.</strong> If you want to restrict your key to only Android apps, you should use the correct package name specified in AndroidManifest.xml. Don’t forget to enable Maps SDK for Android for your project, otherwise, the app won’t work.</p><p>Now run your project and you should see the basic map:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*gfCITzz7YoIFagMh2HE4uQ.png" /></figure><h3>3. Determine and load routes’ coordinates (latitude and longitude of specific points that form the routes)</h3><p>To realize the desired routes, we first need to have a look at Google Maps on a web browser and point out locations where we want to generate directions. It may look very simple like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oqlwNcESEAYLAGcub7-2eQ.png" /></figure><p>In the screenshot above, the route starts from Waterside Restaurant Whalers Inn and traverses around before ends up at the same place. In details, it goes through these locations:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*tqxy_MvFUdydPkh7rLWceA.png" /></figure><p>Next, you need to enable Direction API for your project via <a href="https://console.developers.google.com/">https://console.developers.google.com</a>.</p><p>Now we can run a Directions API request that looks like the form below:</p><pre><a href="https://maps.googleapis.com/maps/api/directions/json?origin=ADDRESS_1&amp;destination=ADDRESS_2&amp;waypoints=ADDRESS_X|ADDRESS_Y&amp;key=API_KEY">https://maps.googleapis.com/maps/api/directions/json?origin=ADDRESS_1&amp;destination=ADDRESS_2&amp;waypoints=ADDRESS_X|ADDRESS_Y&amp;key=API_KEY</a></pre><p>There are 4 parameters associated with the URL above. From Google Developer documentation (learn more about Direction API <a href="https://developers.google.com/maps/documentation/directions/intro">here</a>):</p><p>· Origin — the address, textual latitude/longitude value, or place ID from which you wish to calculate directions.</p><p>· Destination — the address, textual latitude/longitude value, or place ID to which you wish to calculate directions. The options for the destination parameter are the same as for the origin parameter, described above.</p><p>· Waypoints — specifies an array of waypoints. Waypoints alter a route by routing it through the specified location(s). A waypoint is specified as a latitude/longitude coordinate, an encoded polyline, a place ID, or an address which will be geocoded.</p><p>· Key — your application’s API key. This key identifies your application for purposes of quota management.</p><p>In our case, as they are all shuttle buses, the Origin and Destination should be the same address: <em>Waterside Restaurant Whalers Inn, 121 Franklin Parade, Victor Harbor SA 5211</em>. Waypoints are the other addresses that the routes are drawn through. Waypoints are separated by “|”.The final URL should look like this:</p><pre><a href="https://maps.googleapis.com/maps/api/directions/json?origin=Waterside">https://maps.googleapis.com/maps/api/directions/json?origin=Waterside</a> Restaurant Whalers Inn, 121 Franklin Parade, Victor Harbor SA 5211&amp;destination=Waterside Restaurant Whalers Inn, 121 Franklin Parade, Victor Harbor SA 5211&amp;waypoints=8 Franklin Parade, Victor Harbor SA 5211|127 Victoria St, Victor Harbor SA 5211|136 Bay Rd, Encounter Bay SA 5211|45 Whalers Rd, Encounter Bay SA 5211&amp;key=AIzaSyAo5wZVf6wj5ZHwuqp7HB4</pre><p>Note: If you have chosen to automatically generate the API key via the provided link in google_maps_api.xml or you have restricted your key to only Android apps, the generated key is by default restricted to only Android apps, which means that you cannot run the URL above in a web browser on your computer. If you want to run it on a web browser, you need to go to <a href="https://console.developers.google.com/">https://console.developers.google.com</a> and edit restriction to your API key. See screenshot below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/1*L58E0s31j3L70KB7ax9qSw.png" /></figure><p>Once run, the above URL will return a JSON response which comprises all necessary latitude-longitude value pairs for drawing polylines on map:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SbS1DrOoBJOSvug7doBvzQ.png" /></figure><p>You may use <a href="http://jsonviewer.stack.hu/">http://jsonviewer.stack.hu/</a> for more readable JSON format.</p><p>The only value that we will take into account from the JSON response is the <strong>points</strong> attribute’s value within the <strong>overview_polyline</strong> node. This is basically an encoded polyline which can be easily decoded into a list of latitude and longitude value pairs later.</p><p>You may want to run this HTTPS request within your Android app and then parse the JSON response to get the <strong>overview_polyline</strong>.</p><p>However, the Direction API is currently only free for use in 1 year, which means that you will be unable to run the HTTPS request above after 1 year from now with free membership.</p><p>Therefore, if you aren’t ready for a paid subscription yet, you should opt to run this request on your web browser once, then manually copy the <strong>points</strong> attribute’s value within the <strong>overview_polyline</strong> node and store them locally in a CSV file.</p><p>Saving them in a CSV file may make it easy for app developers from other platforms such as iOS or web to retrieve the substantive data. In the screenshot below, “lineBlue” is the keyword for the first polyline, “encodedPoints” is the keyword for the encoded polyline. Those keywords are used to look up encoded polyline strings in our activity classes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/899/1*fkw_YdCBcMNXbfKVfifoLA.png" /></figure><p>Similarly, construct 4 more https requests for the other 4 routes, or you may skip this step and quickly find all the encoded polylines strings in the CSV file from the sample code.</p><h3>4. Render coordinates into polylines</h3><p>Before rendering coordinates to form polylines, we create a helper class named OnMapAndViewReadyListener which implements OnGlobalLayoutListener and OnMapReadyCallback. This will delay triggering the OnMapReady callback until both the GoogleMap and the view has completed initialization.</p><pre>/**</pre><pre>* Helper class that will delay triggering the OnMapReady callback until both the GoogleMap and the</pre><pre>* View having completed initialization. This is only necessary if a developer wishes to immediately</pre><pre>* invoke any method on the GoogleMap that also requires the View to have finished layout</pre><pre>* (ie. anything that needs to know the View&#39;s true size like snapshotting).</pre><pre>*/</pre><pre>public class OnMapAndViewReadyListener implements OnGlobalLayoutListener, OnMapReadyCallback {</pre><pre>/** A listener that needs to wait for both the GoogleMap and the View to be initialized. */</pre><pre>public interface OnGlobalLayoutAndMapReadyListener {</pre><pre>void onMapReady(GoogleMap googleMap);</pre><pre>}</pre><pre>private final SupportMapFragment mapFragment;</pre><pre>private final View mapView;</pre><pre>private final OnGlobalLayoutAndMapReadyListener devCallback;</pre><pre>private boolean isViewReady;</pre><pre>private boolean isMapReady;</pre><pre>private GoogleMap googleMap;</pre><pre>/** Constructor. */</pre><pre>public OnMapAndViewReadyListener(</pre><pre>SupportMapFragment mapFragment, OnGlobalLayoutAndMapReadyListener devCallback) {</pre><pre>this.mapFragment = mapFragment;</pre><pre>mapView = mapFragment.getView();</pre><pre>this.devCallback = devCallback;</pre><pre>isViewReady = false;</pre><pre>isMapReady = false;</pre><pre>googleMap = null;</pre><pre>// Register listener when creating an OnMapAndViewReadyListener object.</pre><pre>registerListeners();</pre><pre>}</pre><pre>/**</pre><pre>* Method to help register a Global Layout Listener for mapView.</pre><pre>* This is necessary to determining if map view has completed layout.</pre><pre>**/</pre><pre>private void registerListeners() {</pre><pre>// View layout.</pre><pre>if ((mapView.getWidth() != 0) &amp;&amp; (mapView.getHeight() != 0)) {</pre><pre>// View has already completed layout.</pre><pre>isViewReady = true;</pre><pre>} else {</pre><pre>// Map has not undergone layout, register a View observer.</pre><pre>mapView.getViewTreeObserver().addOnGlobalLayoutListener(this);</pre><pre>}</pre><pre>// GoogleMap. Note if the GoogleMap is already ready it will still fire the callback later.</pre><pre>mapFragment.getMapAsync(this);</pre><pre>}</pre><pre>/**</pre><pre>* Use the onMapReady(GoogleMap) callback method to get a handle to the GoogleMap object.</pre><pre>**/</pre><pre>@Override</pre><pre>public void onMapReady(GoogleMap googleMap) {</pre><pre>// NOTE: The GoogleMap API specifies the listener is removed just prior to invocation.</pre><pre>this.googleMap = googleMap;</pre><pre>isMapReady = true;</pre><pre>fireCallbackIfReady();</pre><pre>}</pre><pre>/**</pre><pre>* Callback method to be invoked when the global layout state or the visibility of views within</pre><pre>* the view tree changes.</pre><pre>**/</pre><pre>@SuppressWarnings(&quot;deprecation&quot;)  // We use the new method when supported</pre><pre>@SuppressLint(&quot;NewApi&quot;)  // We check which build version we are using.</pre><pre>@Override</pre><pre>public void onGlobalLayout() {</pre><pre>// Remove our listener.</pre><pre>if (Build.VERSION.SDK_INT &lt; Build.VERSION_CODES.JELLY_BEAN) {       mapView.getViewTreeObserver().removeGlobalOnLayoutListener(this);</pre><pre>} else {</pre><pre>mapView.getViewTreeObserver().removeOnGlobalLayoutListener(this);</pre><pre>}</pre><pre>isViewReady = true;</pre><pre>fireCallbackIfReady();</pre><pre>}</pre><pre>/**</pre><pre>* If map view is ready, trigger the callback.</pre><pre>**/</pre><pre>private void fireCallbackIfReady() {</pre><pre>if (isViewReady &amp;&amp; isMapReady) {</pre><pre>devCallback.onMapReady(googleMap);</pre><pre>}</pre><pre>}</pre><pre>}</pre><p>Then implement OnGlobalLayoutAndMapReadyListener from OnMapAndViewReadyListener class in our MapsActivity class.</p><pre>public class MapsActivity extends AppCompatActivity implements</pre><pre>        OnMapReadyCallback,</pre><pre>        OnMapAndViewReadyListener.OnGlobalLayoutAndMapReadyListener</pre><p>Next, once GoogleMap has been initialized on app start, we will want to change the user’s viewpoint of the map to the wanted area by modifying the map’s camera like below:</p><pre>/**</pre><pre> * Bound values for camera focus on app start.</pre><pre> * BOUND1 is the relative coordinates of the bottom-left corner of the bounded area on the map.</pre><pre> * BOUND2 is the relative coordinates of the top-right corner of the bounded area on the map.</pre><pre> */</pre><pre>private static final LatLng BOUND1 = new LatLng(-35.595209, 138.585857);</pre><pre>private static final LatLng BOUND2 = new LatLng(-35.494644, 138.805927);</pre><pre>/**</pre><pre> * Method to move camera to wanted bus area.</pre><pre> */</pre><pre>private void moveCameraToWantedArea() {</pre><pre>    mMap.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() {</pre><pre>        @Override</pre><pre>        public void onMapLoaded() {</pre><pre>            // Set up the bounds coordinates for the area we want the user&#39;s viewpoint to be.</pre><pre>            LatLngBounds bounds = new LatLngBounds.Builder()</pre><pre>                    .include(BOUND1)</pre><pre>                    .include(BOUND2)</pre><pre>                    .build();</pre><pre>            // Move the camera now.</pre><pre>            mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, BOUNDS_PADDING));</pre><pre>        }</pre><pre>    });</pre><pre>}</pre><p>In order to get the relative coordinates of BOUND1 and BOUND2 in the snippet above, just simply use the “What’s here?” feature of Google Maps on a web browser. First, adjust the map to the area or region where you want the users’ viewpoint to be on app start; then right click on the bottom-left and top-right corners of the map view respectively. Choose “What’s here?” and copy the latitude and longitude values that you see in the small popup info windows. See pictures below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tTJH-AbIJ41XgEE26M0erQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fGlvOFcbusu12Q8TeYzTxQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/492/1*2V9KoKAmV36OEInnjKRNYA.png" /></figure><p>And call this method within onMapReady():</p><pre>// Move camera to wanted area.</pre><pre>moveCameraToWantedArea();</pre><p>Next, add this line to your app module’s build.gradle file to add the Maps SDK for Android Utility Library to your project:</p><pre>implementation &#39;com.google.maps.android:android-maps-utils:0.5+&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*BA25y7gvIhj7hYDaD4cJvQ.png" /></figure><p>By making use of adding the Maps SDK for Android Utility Library, we will be converting encoded polylines to latitude/longitude coordinates with just a single line of code.</p><p>Now, create a helper class called Utils.java with a method named readEncodedPolyLinePointsFromCSV(…). This method helps get polyline points by decoding an encoded coordinates string read from the CSV file created earlier:</p><pre>public class Utils {</pre><pre>/**</pre><pre> * Default log tag name for log message.</pre><pre> */</pre><pre>private static final String LOG_TAG = MapsActivity.class.getName();</pre><pre>/**</pre><pre> * Keyword constants for reading values from polylines.csv.</pre><pre> * Important: these keywords values must be exactly the same as ones in polylines.csv file in raw folder.</pre><pre> */</pre><pre>public static final String ENCODED_POINTS = &quot;encodedPoints&quot;;</pre><pre>public static final String LAT_LNG_POINT = &quot;latLngPoint&quot;;</pre><pre>public static final String MARKER = &quot;marker&quot;;</pre><pre>/**</pre><pre> * Helper method to get polyline points by decoding an encoded coordinates string read from CSV file.</pre><pre> */</pre><pre>static List&lt;LatLng&gt; readEncodedPolyLinePointsFromCSV(Context context, String lineKeyword) {</pre><pre>    // Create an InputStream object.</pre><pre>    InputStream is = context.getResources().openRawResource(R.raw.polylines);</pre><pre>    // Create a BufferedReader object to read values from CSV file.</pre><pre>    BufferedReader reader = new BufferedReader(new InputStreamReader(is, Charset.forName(&quot;UTF-8&quot;)));</pre><pre>    String line = &quot;&quot;;</pre><pre>    // Create a list of LatLng objects.</pre><pre>    List&lt;LatLng&gt; latLngList = new ArrayList&lt;&gt;();</pre><pre>    try {</pre><pre>        while ((line = reader.readLine()) != null) {</pre><pre>            // Split the line into different tokens (using the comma as a separator).</pre><pre>            String[] tokens = line.split(&quot;,&quot;);</pre><pre>            // Only add the right latlng points to a desired line by color.</pre><pre>            if (tokens[0].trim().equals(lineKeyword) &amp;&amp; tokens[1].trim().equals(ENCODED_POINTS)) {</pre><pre>                // Use PolyUtil to decode the polylines path into list of LatLng objects.</pre><pre>                latLngList.addAll(PolyUtil.decode(tokens[2].trim().replace(&quot;\\\\&quot;, &quot;\\&quot;)));</pre><pre>                Log.d(LOG_TAG + lineKeyword, tokens[2].trim());</pre><pre>                for (LatLng lat : latLngList) {</pre><pre>                    Log.d(LOG_TAG + lineKeyword, lat.latitude + &quot;, &quot; + lat.longitude);</pre><pre>                }</pre><pre>            } else {</pre><pre>                Log.d(LOG_TAG, &quot;null&quot;);</pre><pre>            }</pre><pre>        }</pre><pre>    } catch (IOException e1) {</pre><pre>        Log.e(LOG_TAG, &quot;Error&quot; + line, e1);</pre><pre>        e1.printStackTrace();</pre><pre>    }</pre><pre>    return latLngList;</pre><pre>}</pre><pre>}</pre><p>Then in your MapsActivity class, create a method called drawAllPolyLines() for drawing all required polylines:</p><pre>/**</pre><pre> * Method to draw all poly lines. This will manually draw polylines one by one on the map by calling</pre><pre> * addPolyline(PolylineOptions) on a map instance. The parameter passed in is a new PolylineOptions</pre><pre> * object which can be configured with details such as line color, line width, clickability, and </pre><pre> * a list of coordinates values. </pre><pre> */</pre><pre>private void drawAllPolyLines() {</pre><pre>    // Add a blue Polyline.</pre><pre>    mMap.addPolyline(new PolylineOptions()</pre><pre>            .color(getResources().getColor(R.color.colorPolyLineBlue)) // Line color.</pre><pre>            .width(POLYLINE_WIDTH) // Line width.</pre><pre>            .clickable(false) // Able to click or not.</pre><pre>            .addAll(readEncodedPolyLinePointsFromCSV(this, LINE_BLUE))); // all the whole list of lat lng value pairs which is retrieved by calling helper method readEncodedPolyLinePointsFromCSV.</pre><pre>    // Add a violet Polyline.</pre><pre>    mMap.addPolyline(new PolylineOptions()</pre><pre>            .color(getResources().getColor(R.color.colorPolyLineViolet))</pre><pre>            .width(POLYLINE_WIDTH)</pre><pre>            .clickable(false)</pre><pre>            .addAll(readEncodedPolyLinePointsFromCSV(this, LINE_VIOLET)));</pre><pre>    // Add an orange Polyline.</pre><pre>    mMap.addPolyline(new PolylineOptions()</pre><pre>            .color(getResources().getColor(R.color.colorPolyLineOrange))</pre><pre>            .width(POLYLINE_WIDTH)</pre><pre>            .clickable(false)</pre><pre>            .addAll(readEncodedPolyLinePointsFromCSV(this, LINE_ORANGE)));</pre><pre>    // Add a green Polyline.</pre><pre>    mMap.addPolyline(new PolylineOptions()</pre><pre>            .color(getResources().getColor(R.color.colorPolyLineGreen))</pre><pre>            .width(POLYLINE_WIDTH)</pre><pre>            .clickable(false)</pre><pre>            .addAll(readEncodedPolyLinePointsFromCSV(this, LINE_GREEN)));</pre><pre>    // Add a pink Polyline.</pre><pre>    mMap.addPolyline(new PolylineOptions()</pre><pre>            .color(getResources().getColor(R.color.colorPolyLinePink))</pre><pre>            .width(POLYLINE_WIDTH)</pre><pre>            .clickable(false)</pre><pre>            .addAll(readEncodedPolyLinePointsFromCSV(this, LINE_PINK)));</pre><pre>}</pre><p>And call this method within onMapReady()</p><pre>// draw all polylines.</pre><pre>drawAllPolyLines();</pre><p>Run the project and the result should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*6jNqfHkKzoag1VtqPcpkYA.png" /></figure><h3>5. Determine markers’ coordinates (bus stops locations)</h3><p>Markers indicate single locations for all of our bus stops on the map.</p><p>First, we will need to identify all the coordinates for our markers (bus stops) on Google Maps. On Google Maps on the web browser, just right-click on a position where you want to get the coordinates and choose “What’s here?”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/893/1*5Ti6HDD5-a3N4hvZzhR--A.png" /></figure><p>A small info window will display:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/492/1*2V9KoKAmV36OEInnjKRNYA.png" /></figure><p>Now you can simply copy the latitudes and longitudes of the desired locations and write them all to polylines.csv:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*w5d99pQR6YzX6wgraUztxA.png" /></figure><h3>6. Add mass bus stop markers on the map</h3><p>Add a helper method in Utils.java class to help resize the drawables used as markers for our bus stops:</p><pre>/**</pre><pre> * Marker bitmap resize tool. This will create a sized bitmap to apply in markers based on input drawable.</pre><pre> */</pre><pre>static Bitmap resizeMarker(Context context, int drawable) {</pre><pre>    BitmapDrawable bitmapDrawable = (BitmapDrawable) context.getResources().getDrawable(drawable);</pre><pre>    Bitmap bitmap = bitmapDrawable.getBitmap();</pre><pre>    // Change expectedWidth&#39;s value to your desired one.</pre><pre>    final int expectedWidth = 60;</pre><pre>    return Bitmap.createScaledBitmap(bitmap, expectedWidth, (bitmap.getHeight() * expectedWidth) / (bitmap.getWidth()), false);</pre><pre>}</pre><p>Then in MapsActivity class, we manipulate that helper method like below:</p><pre>/**</pre><pre> * Method to add all bus stop markers based on line colors.</pre><pre> */</pre><pre>private void addAllBusStopMarkers() {</pre><pre>    addBulkMarkers(MAIN_MARKER);</pre><pre>    addBulkMarkers(LINE_BLUE);</pre><pre>    addBulkMarkers(LINE_ORANGE);</pre><pre>    addBulkMarkers(LINE_VIOLET);</pre><pre>    addBulkMarkers(LINE_GREEN);</pre><pre>    addBulkMarkers(LINE_PINK);</pre><pre>}</pre><pre>/**</pre><pre> * Helper method to add bulk markers to map as per line keyword.</pre><pre> */</pre><pre>private void addBulkMarkers(String lineKeyword) {</pre><pre>    // Create a list of LatLng objects and load all of the markers coordinates from CSV file.</pre><pre>    List&lt;LatLng&gt; latLngList = readMarkersFromCSV(this, lineKeyword);</pre><pre>    // Create a Bitmap object that holds the right resized marker image based on line color.</pre><pre>    Bitmap resizedBitmap = resizeMarker(this, R.drawable.marker_blue_dark);</pre><pre>    switch (lineKeyword) {</pre><pre>        case LINE_BLUE:</pre><pre>            resizedBitmap = resizeMarker(this, R.drawable.marker_blue_light);</pre><pre>            break;</pre><pre>        case LINE_ORANGE:</pre><pre>            resizedBitmap = resizeMarker(this, R.drawable.marker_orange);</pre><pre>            break;</pre><pre>        case LINE_VIOLET:</pre><pre>            resizedBitmap = resizeMarker(this, R.drawable.marker_violet);</pre><pre>            break;</pre><pre>        case LINE_GREEN:</pre><pre>            resizedBitmap = resizeMarker(this, R.drawable.marker_green);</pre><pre>            break;</pre><pre>        case LINE_PINK:</pre><pre>            resizedBitmap = resizeMarker(this, R.drawable.marker_pink);</pre><pre>            break;</pre><pre>        case MAIN_MARKER:</pre><pre>            resizedBitmap = resizeMarker(this, R.drawable.marker_blue_dark);</pre><pre>            break;</pre><pre>    }</pre><pre>    // For each of LatLng object in the latLngList, add a relevant marker with the right latitude</pre><pre>// and longitude values and bitmap image. </pre><pre>for (LatLng latLng : latLngList) {</pre><pre>    mMap.addMarker(new MarkerOptions()</pre><pre>            .position(new LatLng(latLng.latitude, latLng.longitude))</pre><pre>            .icon(BitmapDescriptorFactory.fromBitmap(resizedBitmap))</pre><pre>            .title(&quot;Bus Stop&quot;) // Title of info window displayed on marker click.</pre><pre>            .snippet(&quot;This is a bus stop&quot;)); // Content of info window displayed on marker click.</pre><pre>}</pre><pre>}</pre><p>And call this method within onMapReady():</p><pre>// Add all markers (bus stops) to the map.</pre><pre>addAllBusStopMarkers();</pre><p>Run the project and the result should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*xvKgGr78JHswZoDy9Ct5eg.png" /></figure><p>When you click on a marker, a small info window should display:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*g7z7lOCdQ5qmXPREcWw-qw.png" /></figure><h3>7. Determine annotations’ coordinates</h3><p>Each bus stop has a unique annotation attached alongside. In order for these annotations to be displayed on the map, we have to utilize either Ground Overlays or Markers feature of the Map SDK.</p><p>According to Google developer docs, ground overlays are image overlays that are tied to latitude/longitude coordinates, so they move when you drag or zoom the map. Just like markers, they are fixed to a map, but unlike markers, ground overlays are oriented against the Earth’s surface rather than the screen, so rotating, tilting or zooming the map will change the orientation of the image. Ground overlays are useful when you wish to fix a single image at one area on the map.</p><p>In our app, we will be laying all of our annotation texts on the map as Markers, not Ground Overlays because we don’t want them to change sizes when zooming the map. See 2 pictures below for comparison:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*Fdj8RobGw4KUBOgfbP_l7g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*8VZnlsNsnOjjhdJmBue-kQ.png" /></figure><p>Now we need to manually select relative positions of these annotations on Google Maps just like identifying bus stops’ coordinates in step 5.</p><p>You may get annotations’ coordinates one by one from Google Maps on your web browser and follow through step 8 below.</p><h3>8. Add all annotations as markers on the map</h3><p>Annotations in our app are just simply texts. To style them nicely as you can see in the app design, we need to either create them as PNG images by using a photo editor tool like Photoshop or programmatically generate them using Bitmap and Canvas classes. To simplify, we opt to use the first solution. You can find all of these annotation images in the sample code package or you may make up your own images.</p><p>The helper method resizeCommonAnnotation(…) helps adjust the size of every annotation image accordingly. Add it to your Utils.java class:</p><pre>/**</pre><pre> * Annotation bitmap resize tool. This will create a sized bitmap to apply in annotations based on input drawable.</pre><pre> */</pre><pre>static Bitmap resizeCommonAnnotation(Context context, int drawable) {</pre><pre>    BitmapDrawable bitmapDrawable = (BitmapDrawable) context.getResources().getDrawable(drawable);</pre><pre>    Bitmap bitmap = bitmapDrawable.getBitmap();</pre><pre>    // Change scale&#39;s value to your desired one.</pre><pre>    float scale = 0.15f;</pre><pre>    int newWidth = (int) (bitmapDrawable.getBitmap().getWidth() * scale);</pre><pre>    int newHeight = (int) (bitmapDrawable.getBitmap().getHeight() * scale);</pre><pre>    return Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, false);</pre><pre>}</pre><p>In your MapsActivity class, add addAllAnnotationsAsMarkers() method to help add all of the annotations to our map. Add your first annotation like below:</p><pre>private void addAllAnnotationsAsMarkers() {</pre><pre>    mMap.addMarker(new MarkerOptions()</pre><pre>            .icon(BitmapDescriptorFactory.fromBitmap(resizeCommonAnnotation(R.drawable.anno_whalers_inn)))</pre><pre>            .anchor(0, 0.5f)</pre><pre>            .position(new LatLng(-35.5863, 138.59842))</pre><pre>    );</pre><pre>}</pre><p>According to Google developer docs, method anchor(…) specifies the anchor at a particular point in the marker image. The anchor specifies the point in the icon image that is anchored to the marker’s position on the Earth’s surface.</p><p>The anchor point is specified in the continuous space [0.0, 1.0] x [0.0, 1.0], where (0, 0) is the top-left corner of the image, and (1, 1) is the bottom-right corner. The anchoring point in a <em>W</em> x <em>H</em> image is the nearest discrete grid point in a <em>(W + 1)</em> x <em>(H + 1)</em> grid, obtained by scaling them then rounding. For example, in a 4 x 2 image, the anchor point (0.7, 0.6) resolves to the grid point at (3, 1):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/467/1*jCdVkIXyJ5bprMz1qCQIog.png" /></figure><p>Now step by step manually append the remaining annotations as markers to addAllAnnotationsAsMarkers() method above (find a whole lot of code in the downloaded sample package).</p><p>Lastly, call the method addAllAnnotationsAsMarkers() in onMapReady():</p><pre>// Add all annotations as markers on map.</pre><pre>addAllAnnotationsAsMarkers();</pre><p>Run your project and you should see this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*saWmal8KAOxMn4NSbN1-YQ.png" /></figure><h3>9. Determine arrows’ coordinates</h3><p>We are going to add all of the directional arrows along the bus routes as Ground Overlays on the map. By doing this, the arrows’ sizes will change proportionally with the zooming level of the map.</p><p>Similar to specifying markers’ coordinates as described in step 5, utilize the google maps “What’s here” feature to get directional arrows’ coordinates one by one. Then follow step 10.</p><h3>10. Add all directional arrows as Ground Overlays on map</h3><p>Add your first arrow by adding the codes below to your MapsActivity class:</p><pre>/**</pre><pre> * Default width of directional arrows.</pre><pre> */</pre><pre>private static final float DIRECTION_ARROW_WIDTH = 400f;</pre><pre>/**</pre><pre> * List of GroundOverlay objects.</pre><pre> */</pre><pre>private List&lt;GroundOverlay&gt; mGroundOverlay = new ArrayList&lt;&gt;();</pre><pre>/**</pre><pre> * Method to add all directional arrows as ground overlay images.</pre><pre> * The bearing(…) method specifies the bearing of the ground overlay in degrees clockwise from north.</pre><pre> * The rotation is performed about the anchor point.</pre><pre> * If not specified, the default is 0 (i.e., up on the image points north).</pre><pre> * Values outside the range [0, 360) will be normalized (Google developer docs).</pre><pre> * DIRECTION_ARROW_WIDTH specifies the default width of the Ground Overlays</pre><pre> */</pre><pre>private void addAllDirectionArrowsAsGroundOverlay() {</pre><pre>    // blue arrows</pre><pre>    mGroundOverlay.add(mMap.addGroundOverlay(new GroundOverlayOptions()</pre><pre>            .image(BitmapDescriptorFactory.fromResource(R.drawable.arrow_blue))</pre><pre>            .anchor(0, 0.5f)</pre><pre>            .position(new LatLng(-35.586970, 138.597452), DIRECTION_ARROW_WIDTH)</pre><pre>            .bearing(250)</pre><pre>            .clickable(false)));</pre><pre>}</pre><p>Looking at the code snippet above, bearing(…) method specifies the bearing of the ground overlay in degrees clockwise from north. The rotation is performed about the anchor point. If not specified, the default is 0 (i.e., upon the image points north). Values outside the range [0, 360) will be normalized (Google developer docs).</p><p>Now step by step manually append the remaining arrows as Ground Overlays to addAllDirectionArrowsAsGroundOverlay() method above (find a whole lot of codes in the downloaded sample package).</p><p>Lastly, call this method in onMapReady():</p><pre>// Add all directional arrows.</pre><pre>addAllDirectionArrowsAsGroundOverlay();</pre><p>Run your project and you should see the final result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*J1WFiO39L_jwwVeDEItdEg.png" /></figure><p>Hope you enjoy the tutorial. We welcome all feedback and questions from you. <a href="https://www.digital-noir.com/contact/">Contact us</a> now!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=44765433f19" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>