{"id":272052,"date":"2016-01-13T12:44:02","date_gmt":"2016-01-13T09:44:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=272052"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=272052","title":{"rendered":"\u041c\u0430\u0440\u0448\u0440\u0443\u0442\u044b \u043d\u0430 \u043a\u0430\u0440\u0442\u0430\u0445 Google \u0432 Android-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u2014 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0442\u043e\u0447\u043d\u0435\u043d\u0438\u044f"},"content":{"rendered":"<p>       \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044f \u044f\u0432\u043b\u044f\u044e\u0441\u044c \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u043c \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438, \u0442\u043e \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0441\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u043c\u0438 \u0438\u0434\u0435\u044f\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c \u0441\u0443\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432\u044b\u0445 \u0437\u0430\u0434\u0430\u0447. \u0412 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043c\u043d\u0435 \u0441\u0442\u0430\u043b\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0441\u0445\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043c\u0430\u0440\u0448\u0440\u0443\u0442 \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0442\u043e\u0447\u043a\u0430\u043c\u0438 \u043d\u0430 \u043a\u0430\u0440\u0442\u0430\u0445 Google. \u0421\u0430\u043c\u044b\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c \u0430\u043d\u0430\u043b\u043e\u0433\u043e\u043c \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438, \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u043c \u0432 \u0441\u0435\u0442\u0438 \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442, \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439: &quot;<a href=\"http:\/\/habrahabr.ru\/post\/244229\/\">\u041c\u0430\u0440\u0448\u0440\u0443\u0442\u044b \u043d\u0430 \u043a\u0430\u0440\u0442\u0430\u0445 Google \u0432 Android-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438<\/a>&quot;. \u041e\u0434\u043d\u0430\u043a\u043e, \u043f\u0440\u0438 \u0435\u0433\u043e \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u0438 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0435 \u043a\u0430\u043c\u043d\u0438, \u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044f \u0438 \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0412\u043e \u043f\u0435\u0440\u0432\u044b\u0445, \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0434\u0432\u0443\u0445 \u043c\u0430\u0440\u043a\u0435\u0440\u043e\u0432 \u0434\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043d\u043e\u0439 \u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u0435\u043a. \u041c\u043e\u0436\u0435\u0442 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0438 \u043a\u0440\u0438\u0432\u043e, \u043d\u043e \u044f \u0432\u044b\u0431\u0440\u0430\u043b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u2014 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u0437\u0430 \u0438\u0445 \u043d\u0430\u043b\u0438\u0447\u0438\u0435\u043c \u0441 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438 \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435. \u041f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"java\">\/\/ \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u044f \u043a\u043b\u0438\u043a\u043e\u0432 \u043f\u043e \u043a\u0430\u0440\u0442\u0435 map.setOnMapClickListener(new GoogleMap.OnMapClickListener() {       \/\/ \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043a\u043b\u0438\u043a\u043e\u0432      @Override      public void onMapClick(LatLng latlng) {            if ((fromMarker == false) && (toMarker == false)) {            MarkerOptions markerOptions = new MarkerOptions();            markerOptions.position(latlng);            markerOptions.title(&quot;&quot; + latlng.latitude + &quot; &quot; + latlng.longitude);            BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.            fromResource(R.drawable.a_marker);            markerOptions.icon(bitmapDescriptor);            \/\/\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b &quot;from - \u0438\u0437&quot; \u0438 &quot;to - \u0432&quot; - \u0437\u0430\u0434\u0430\u044e\u0442\u0441\u044f, \u043a\u0430\u043a \u0441\u0442\u0440\u043e\u043a\u0438, \u0438 \u0431\u0443\u0434\u0443\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a \u0441\u0442\u0440\u043e\u043a\u0438            from=&quot;&quot;+latlng.latitude+&quot;,&quot;+latlng.longitude;            map.addMarker(markerOptions);            fromMarker = true;            }             else {                    if ((fromMarker == true) && (toMarker == false)) {                    MarkerOptions markerOptions = new MarkerOptions();                    markerOptions.position(latlng);                    markerOptions.title(&quot;&quot; + latlng.latitude + &quot; &quot; + latlng.longitude);                    BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.                    fromResource(R.drawable.b_marker);                    markerOptions.icon(bitmapDescriptor);                    to=&quot;&quot;+latlng.latitude+&quot;,&quot;+latlng.longitude;                    map.addMarker(markerOptions);                    toMarker = true;                    } else {                              if ((fromMarker == true) && (toMarker == true)) {                              map.clear();                              fromMarker = false;                              toMarker = false;                              }                              }                   }          } }); <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043c\u0430\u0440\u043a\u0435\u0440\u043e\u0432 \u0438 \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u044f \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0445 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442, \u0441\u0442\u0430\u043b \u0432\u043e\u043f\u0440\u043e\u0441 \u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430. \u041f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u0432 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u0432\u044b\u0448\u0435 \u0441\u0442\u0430\u0442\u044c\u0435 \u00ab\u041c\u0430\u0440\u0448\u0440\u0443\u0442\u044b \u043d\u0430 \u043a\u0430\u0440\u0442\u0430\u0445 Google \u0432 Android-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438\u00bb \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b\u043c.<\/p>\n<p>  \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c \u043a \u0441\u0430\u0439\u0442\u0443 <a href=\"https:\/\/maps.googleapis.com\">maps.googleapis.com<\/a>. \u041e\u0448\u0438\u0431\u043a\u0430 \u0432\u044b\u0440\u0430\u0436\u0430\u043b\u0430\u0441\u044c \u0432 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 GET \u0441 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435\u0439 \u0432 \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a. \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0430\u0441\u044c \u043d\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435 \u0441 Android 5,0. \u041f\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044e, \u0430\u0432\u0442\u043e\u0440 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0434\u0435\u043b\u0430\u0435\u0442 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 GET \u0437\u0430\u043f\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043c\u0435\u0435\u0442 \u0432\u0438\u0434:<\/p>\n<pre><code class=\"java\">public interface RouteApi {     @GET(&quot;\/maps\/api\/directions\/json&quot;)     RouteResponse getRoute(             @Query(value = &quot;origin&quot;, encodeValue = false) String position,             @Query(value = &quot;destination&quot;, encodeValue = false) String destination,             @Query(&quot;sensor&quot;) boolean sensor,             @Query(&quot;language&quot;) String language); } <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u0448\u0438\u0431\u043a\u0443 \u0434\u0430\u0432\u0430\u043b \u0438\u043c\u0435\u043d\u043d\u043e Retrofit, \u043d\u0430 \u0431\u0430\u0437\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u044b \u0432\u0441\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438 \u043f\u0430\u0440\u0441\u0438\u043d\u0433 JSON-\u043e\u0442\u0432\u0435\u0442\u0430, \u0442\u043e \u0440\u0435\u0448\u0435\u043d\u043e \u0431\u044b\u043b\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u043d\u0435\u043c. \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u0441\u0442\u0430\u0442\u044c\u0435\u0439 \u2014 \u00abRetrofit \u2013 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 REST API\u00bb \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 <a href=\"http:\/\/java-help.ru\/retrofit-library\/\">java-help.ru\/retrofit-library<\/a>.<\/p>\n<p>  \u041f\u043e\u043c\u043d\u044f, \u0447\u0442\u043e \u0440\u0430\u043d\u0435\u0435 \u0432 \u0441\u0442\u0430\u0442\u044c\u044f\u0445 \u043f\u0438\u0441\u0430\u043b\u043e\u0441\u044c \u043e \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0432 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a \u0441\u0435\u0442\u0438, \u0431\u044b\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0435\u043b\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u0432 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"java\">   \/\/\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430     public interface RouteApi {         @GET(&quot;\/maps\/api\/directions\/json&quot;)         void getRoute(                 @Query(value = &quot;origin&quot;, encodeValue = false) String position,                 @Query(value = &quot;destination&quot;, encodeValue = false) String destination,                 @Query(&quot;sensor&quot;) boolean sensor,                 @Query(&quot;language&quot;) String language,                 Callback&lt;RouteResponse&gt; cb         );     } <\/code><\/pre>\n<p>  \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043a\u043e\u0434\u0435. \u0412\u043c\u0435\u0441\u0442\u043e:<\/p>\n<pre><code class=\"java\">RestAdapter restAdapter = new RestAdapter.Builder()     .setEndpoint(&quot;https:\/\/maps.googleapis.com&quot;)     .build(); RouteApi routeService = restAdapter.create(RouteApi.class); RouteResponse routeResponse = routeService.getRoute(position, destination, true, &quot;ru&quot;); <\/code><\/pre>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c:<\/p>\n<pre><code class=\"java\">        \/\/\u041f\u0435\u0440\u0435\u0445\u043e\u0434 \u043e\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u043a API         RestAdapter restAdapter = new RestAdapter.Builder()                 .setEndpoint(&quot;https:\/\/maps.googleapis.com&quot;)                 .setLogLevel(RestAdapter.LogLevel.FULL)                 .build();         RouteApi routeService = restAdapter.create(RouteApi.class);          \/\/\u0412\u044b\u0437\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430 \u043c\u0430\u0440\u0448\u0440\u0443\u0442 (\u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d)         routeService.getRoute(from, to, true, &quot;ru&quot;, new Callback&lt;RouteResponse&gt;() {          public void success(RouteResponse arg0, retrofit.client.Response arg1) {         }          public void failure(RetrofitError arg0) {         }                 }); <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e, \u043f\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0443 \u043d\u0430\u0447\u0430\u043b \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f JSON-\u043e\u0442\u0432\u0435\u0442 \u0431\u0435\u0437 \u043e\u0448\u0438\u0431\u043e\u043a. <\/p>\n<p>  \u0412 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0438\u0437 \u0432\u0441\u0435\u0433\u043e \u043a\u043e\u0434\u0430 \u043c\u0430\u0440\u0448\u0440\u0443\u0442 \u0438 \u043e\u0442\u0440\u0430\u0437\u0438\u0442\u044c \u0435\u0433\u043e \u043d\u0430 \u043a\u0430\u0440\u0442\u0435. \u0410\u0432\u0442\u043e\u0440 \u0446\u0438\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442, \u0447\u0442\u043e \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0442\u043e\u0447\u0435\u043a \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u043c PolyUtil. \u0426\u0438\u0442\u0438\u0440\u0443\u044e: &quot;&#8230;PolyUtil \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u0435\u0442\u043e\u0434 decode(), \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0438\u0439 \u0441\u0442\u0440\u043e\u043a\u0443 Points \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439 \u043d\u0430\u0431\u043e\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 LatLng, \u0443\u0437\u043b\u043e\u0432 \u043d\u0430\u0448\u0435\u0433\u043e \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430. \u042d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u043c\u0430\u0440\u0448\u0440\u0443\u0442 \u043d\u0430 \u043a\u0430\u0440\u0442\u0435.&quot; \u041e\u0434\u043d\u0430\u043a\u043e, \u043e\u0431\u0440\u0430\u0437\u0446\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u043d\u0435\u0442. \u0412 \u043c\u043e\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"java\">        \/\/\u0412\u044b\u0437\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430 \u043c\u0430\u0440\u0448\u0440\u0443\u0442 (\u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d)         routeService.getRoute(from, to, true, &quot;ru&quot;, new Callback&lt;RouteResponse&gt;() {             public void success(RouteResponse arg0, retrofit.client.Response arg1) {                 \/\/\u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0448\u043b\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u043e, \u0442\u043e \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u0443\u0435\u043c \u043c\u0430\u0440\u0448\u0440\u0443\u0442 \u0432 \u0442\u043e\u0447\u043a\u0438 LatLng                 List&lt;LatLng&gt; mPoints = PolyUtil.decode(arg0.getPoints()); <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u043e\u043b\u0438\u043b\u0438\u043d\u0438\u044e \u043c\u0435\u0442\u043e\u0434\u043e\u043c, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u043c \u0443 \u0430\u0432\u0442\u043e\u0440\u0430.<\/p>\n<p>  \u0418\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u0438\u0434:<\/p>\n<pre><code class=\"java\">package com.example.gpstest;  import android.location.LocationManager; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.view.View; import com.google.android.gms.location.LocationListener; import com.google.android.gms.maps.CameraUpdate; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.SupportMapFragment; import com.google.android.gms.maps.model.BitmapDescriptor; import com.google.android.gms.maps.model.BitmapDescriptorFactory; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.LatLngBounds; import com.google.android.gms.maps.model.Marker; import com.google.android.gms.maps.model.MarkerOptions; import com.google.android.gms.maps.model.PolylineOptions; import com.google.maps.android.PolyUtil; import java.util.List; import retrofit.Callback; import retrofit.RestAdapter; import retrofit.RetrofitError; import retrofit.http.GET; import retrofit.http.Query;  public class MainActivity extends FragmentActivity {      SupportMapFragment mapFragment;     GoogleMap map;      private LocationManager locationManager;     private LocationListener locationListener;     Marker label;     boolean fromMarker, toMarker;     String from, to,result;      @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);         fromMarker = false;         toMarker = false;         \/\/\u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c \u043a\u0430\u0440\u0442\u0443 \u043d\u0430 \u0432\u044b\u0432\u043e\u0434         mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);         map = mapFragment.getMap();         map.getUiSettings().setZoomControlsEnabled(true);         map.setMyLocationEnabled(true);          if (map == null) {             return;         }         \/\/\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043a\u043b\u0438\u043a\u0430 \u043d\u0430 \u043a\u0430\u0440\u0442\u0443         \/\/\u0415\u0441\u043b\u0438 \u043d\u0435\u0442 \u043c\u0430\u0440\u043a\u0435\u0440\u043e\u0432, \u0442\u043e \u0441\u0442\u0430\u0432\u0438\u043c \u0410, \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0410 - \u0441\u0442\u0430\u0432\u0438\u043c B, \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u043e\u0431\u0430 - \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u043c \u0438 \u0432\u0432\u043e\u0434\u0438\u043c \u0437\u0430\u043d\u043e\u0432\u043e         map.setOnMapClickListener(new GoogleMap.OnMapClickListener() {              @Override             public void onMapClick(LatLng latlng) {                 if ((fromMarker == false) && (toMarker == false)) {                     MarkerOptions markerOptions = new MarkerOptions();                     markerOptions.position(latlng);                     markerOptions.title(&quot;&quot; + latlng.latitude + &quot; &quot; + latlng.longitude);                     BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.a_marker);                     markerOptions.icon(bitmapDescriptor);                     from=&quot;&quot;+latlng.latitude+&quot;,&quot;+latlng.longitude;                     map.addMarker(markerOptions);                     fromMarker = true;                 } else {                     if ((fromMarker == true) && (toMarker == false)) {                         MarkerOptions markerOptions = new MarkerOptions();                         markerOptions.position(latlng);                         markerOptions.title(&quot;&quot; + latlng.latitude + &quot; &quot; + latlng.longitude);                         BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.b_marker);                         markerOptions.icon(bitmapDescriptor);                         to=&quot;&quot;+latlng.latitude+&quot;,&quot;+latlng.longitude;                         map.addMarker(markerOptions);                         toMarker = true;                     } else {                         if ((fromMarker == true) && (toMarker == true)) {                             map.clear();                             fromMarker = false;                             toMarker = false;                         }                     }                 }             }         });     }       \/\/\u041a\u043b\u0430\u0441\u0441 \u0442\u043e\u0447\u043a\u0438 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f     public class RouteResponse {          public List&lt;Route&gt; routes;          public String getPoints() {             return this.routes.get(0).overview_polyline.points;         }          class Route {             OverviewPolyline overview_polyline;         }          class OverviewPolyline {             String points;         }     }     \/\/\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043a \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430     public interface RouteApi {         @GET(&quot;\/maps\/api\/directions\/json&quot;)         void getRoute(                 @Query(value = &quot;origin&quot;, encodeValue = false) String position,                 @Query(value = &quot;destination&quot;, encodeValue = false) String destination,                 @Query(&quot;sensor&quot;) boolean sensor,                 @Query(&quot;language&quot;) String language,                 Callback&lt;RouteResponse&gt; cb         );     }      \/\/ \u043c\u0435\u0442\u043e\u0434 \u043f\u043e\u043a\u0430\u0437\u0430 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430     public void showRoute(View view ) {         \/\/\u041f\u0435\u0440\u0435\u0445\u043e\u0434 \u043e\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u043a API         RestAdapter restAdapter = new RestAdapter.Builder()                 .setEndpoint(&quot;https:\/\/maps.googleapis.com&quot;)                 .setLogLevel(RestAdapter.LogLevel.FULL)                 .build();         RouteApi routeService = restAdapter.create(RouteApi.class);          \/\/\u0412\u044b\u0437\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430 \u043c\u0430\u0440\u0448\u0440\u0443\u0442 (\u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d)         routeService.getRoute(from, to, true, &quot;ru&quot;, new Callback&lt;RouteResponse&gt;() {             public void success(RouteResponse arg0, retrofit.client.Response arg1) {                 \/\/\u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0448\u043b\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u043e, \u0442\u043e \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u0443\u0435\u043c \u043c\u0430\u0440\u0448\u0440\u0443\u0442 \u0432 \u0442\u043e\u0447\u043a\u0438 LatLng                 List&lt;LatLng&gt; mPoints = PolyUtil.decode(arg0.getPoints());                 \/\/\u0421\u0442\u0440\u043e\u0438\u043c \u043f\u043e\u043b\u0438\u043b\u0438\u043d\u0438\u044e                 PolylineOptions line = new PolylineOptions();                 line.width(4f).color(R.color.colorPrimary);                 LatLngBounds.Builder latLngBuilder = new LatLngBounds.Builder();                 for (int i = 0; i &lt; mPoints.size(); i++) {                      line.add((LatLng) mPoints.get(i));                     latLngBuilder.include((LatLng) mPoints.get(i));                 }                 map.addPolyline(line);                 int size = getResources().getDisplayMetrics().widthPixels;                 LatLngBounds latLngBounds = latLngBuilder.build();                 CameraUpdate track = CameraUpdateFactory.newLatLngBounds(latLngBounds, size, size, 25);                 map.moveCamera(track);                 }             \/\/\u0415\u0441\u043b\u0438 \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u0440\u043e\u0448\u0435\u043b \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u043e             public void failure(RetrofitError arg0) {             }         });     } } <\/code><\/pre>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0438\u0436\u0435 \u043d\u0430 \u0441\u043a\u0440\u0438\u043d\u0435:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/466\/831\/f1c\/466831f1cea14c42bdba4fdd440e09f9.png\"\/><\/p>\n<p>  \u0421\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u043f\u0440\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u0437\u0430\u0434\u0430\u0447\u0438:<\/p>\n<p>  <a href=\"http:\/\/java-help.ru\/retrofit-library\/\">Retrofit \u2013 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 REST API<\/a><br \/>  <a href=\"http:\/\/square.github.io\/retrofit\/\">A type-safe HTTP client for Android and Java<\/a><br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/244229\/\">\u041c\u0430\u0440\u0448\u0440\u0443\u0442\u044b \u043d\u0430 \u043a\u0430\u0440\u0442\u0430\u0445 Google \u0432 Android-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438<\/a>       <\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/275019\/\"> http:\/\/habrahabr.ru\/post\/275019\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044f \u044f\u0432\u043b\u044f\u044e\u0441\u044c \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u043c \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438, \u0442\u043e \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0441\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u043c\u0438 \u0438\u0434\u0435\u044f\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c \u0441\u0443\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432\u044b\u0445 \u0437\u0430\u0434\u0430\u0447. \u0412 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043c\u043d\u0435 \u0441\u0442\u0430\u043b\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0441\u0445\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043c\u0430\u0440\u0448\u0440\u0443\u0442 \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0442\u043e\u0447\u043a\u0430\u043c\u0438 \u043d\u0430 \u043a\u0430\u0440\u0442\u0430\u0445 Google. \u0421\u0430\u043c\u044b\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c \u0430\u043d\u0430\u043b\u043e\u0433\u043e\u043c \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438, \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u043c \u0432 \u0441\u0435\u0442\u0438 \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442, \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439: &quot;<a href=\"http:\/\/habrahabr.ru\/post\/244229\/\">\u041c\u0430\u0440\u0448\u0440\u0443\u0442\u044b \u043d\u0430 \u043a\u0430\u0440\u0442\u0430\u0445 Google \u0432 Android-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438<\/a>&quot;. \u041e\u0434\u043d\u0430\u043a\u043e, \u043f\u0440\u0438 \u0435\u0433\u043e \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u0438 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0435 \u043a\u0430\u043c\u043d\u0438, \u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044f \u0438 \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-272052","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/272052","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=272052"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/272052\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=272052"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=272052"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=272052"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}