当前位置: 首页>>代码示例>>Java>>正文


Java PolyUtil.decode方法代码示例

本文整理汇总了Java中com.google.maps.android.PolyUtil.decode方法的典型用法代码示例。如果您正苦于以下问题:Java PolyUtil.decode方法的具体用法?Java PolyUtil.decode怎么用?Java PolyUtil.decode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.maps.android.PolyUtil的用法示例。


在下文中一共展示了PolyUtil.decode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Step

import com.google.maps.android.PolyUtil; //导入方法依赖的package包/类
public Step(JSONObject jsonObject) throws JSONException {
        start = new Location("");
        end = new Location("");

        start.setLongitude(jsonObject.getJSONObject("start_location").getDouble("lng"));
        start.setLatitude(jsonObject.getJSONObject("start_location").getDouble("lat"));
        end.setLongitude(jsonObject.getJSONObject("end_location").getDouble("lng"));
        end.setLatitude(jsonObject.getJSONObject("end_location").getDouble("lat"));
//        street = jsonObject.getJSONArray("streets").length() > 0 ? jsonObject.getJSONArray("streets").getString(0) : "";
//        turnType = jsonObject.getInt("turnType");
        maneuver = jsonObject.has("maneuver") ? jsonObject.getString("maneuver") : "";
        narrative = jsonObject.getString("html_instructions");
        distance = jsonObject.getJSONObject("distance").getLong("value");
        polyline = PolyUtil.decode(jsonObject.getJSONObject("polyline").getString("points"));

    }
 
开发者ID:snigle,项目名称:corsaire,代码行数:17,代码来源:Step.java

示例2: onMapReady

import com.google.maps.android.PolyUtil; //导入方法依赖的package包/类
@Override
public void onMapReady(GoogleMap googleMap) {
	MapsInitializer.initialize(getActivity()); // required for the CameraUpdateFactory to be initialized
	googleMap.clear();
	googleMap.setMyLocationEnabled(true);

	googleMap.addMarker(new MarkerOptions().position(fromLocation).title(fromTitle));
	googleMap.addMarker(new MarkerOptions().position(toLocation).title(toTitle));

	List<LatLng> route = PolyUtil.decode(encodedRoute);
	googleMap.addPolyline(new PolylineOptions().addAll(route).color(R.color.green));

	LatLngBounds bounds = new LatLngBounds.Builder()
			.include(fromLocation)
			.include(toLocation)
			.build();
	googleMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 100));
}
 
开发者ID:FauDroids,项目名称:TripWeather,代码行数:19,代码来源:MapFragment.java

示例3: onMapReady

import com.google.maps.android.PolyUtil; //导入方法依赖的package包/类
@Override
public void onMapReady() {
    if (mGoogleMap == null) {
        mGoogleMap = mMapFragment.getMap();
        if (mGoogleMap != null) {
            // You are good to use the map =)
            final UiSettings uiSettings = mGoogleMap.getUiSettings();
            uiSettings.setCompassEnabled(false);
            uiSettings.setZoomControlsEnabled(false);

            // Draw the paths
            if (!mDrawing.getEncodedPolylines().isEmpty()) {
                final LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder();
                for (String encodedPath : mDrawing.getEncodedPolylines()) {
                    final List<LatLng> pathPoints = PolyUtil.decode(encodedPath);
                    mGoogleMap.addPolyline(mPathOptions).setPoints(pathPoints);
                    for (LatLng point : pathPoints) {
                        boundsBuilder.include(point);
                    }
                }
                animateCameraToBounds(boundsBuilder.build());
                mDrawingLength.setText(getString(R.string.activity_drawing_viewer_drawing_length, mDrawing.getLength()));
            }
        }
    }
}
 
开发者ID:tvbarthel,项目名称:SayItFromTheSky,代码行数:27,代码来源:DrawingViewerActivity.java

示例4: parseRoutes

import com.google.maps.android.PolyUtil; //导入方法依赖的package包/类
/**
 * Parses the route information JSON string into a list of routes.
 */
private List<Route> parseRoutes(String json) {
    List<Route> routes = new ArrayList<Route>();
    try {
        JSONObject jsonObject = new JSONObject(json);
        JSONArray jRoutes = jsonObject.getJSONArray("routes");

        int len = jRoutes.length();
        for (int i = 0; i < len; i++) {
            JSONObject jobj = jRoutes.getJSONObject(i);
            Route route = new Route();

            route.name = jobj.getString("Name");
            route.polyLine = jobj.getString("Polyline");
            route.polyLinePositions = PolyUtil.decode(route.polyLine);
            route.color = jobj.getString("Color");
            route.stopList = parseStops(jobj);
            routes.add(route);
        }
    } catch (JSONException e) {
        Log.d(logTag, "JSONException occurred when getting routes as an array!", e);
    }

    return routes;
}
 
开发者ID:cartermp,项目名称:WMB,代码行数:28,代码来源:RoutesTask.java

示例5: DirectionsTaskResponse

import com.google.maps.android.PolyUtil; //导入方法依赖的package包/类
public DirectionsTaskResponse(JSONObject jsonObject) throws JSONException {
    JSONObject route = jsonObject.getJSONArray("routes").getJSONObject(0);
    JSONObject leg = route.getJSONArray("legs").getJSONObject(0);
    List<LatLng> polylinePoints =
            PolyUtil.decode(route.getJSONObject("overview_polyline").getString("points"));
    polylineOptions = new PolylineOptions().addAll(polylinePoints).width(5f).color(Color.RED);
    distanceString = leg.getJSONObject("distance").getString("text");
    distance = leg.getJSONObject("distance").getInt("value");
}
 
开发者ID:rasmussaks,项目名称:aken-ajalukku,代码行数:10,代码来源:DirectionsTaskResponse.java

示例6: getPolylineOptions

import com.google.maps.android.PolyUtil; //导入方法依赖的package包/类
/**
 * Gets polyline options for polyline.
 * @param latLngBoundsBuilder the bounds
 * @param polylineData the polyline
 * @return the polyline options
 */
public PolylineOptions getPolylineOptions(LatLngBounds.Builder latLngBoundsBuilder, PolylineData polylineData) {
	PolylineOptions polyline = new PolylineOptions();
	String encodedValue = polylineData.getEncodedValue();
	if (encodedValue == null) {
		return null;
	}
	List<LatLng> latLngList = PolyUtil.decode(encodedValue);
	for (LatLng latLng : latLngList) {
		latLngBoundsBuilder.include(latLng);
	}
	polyline.addAll(latLngList);
	polyline.color(polylineData.getColor());
	return polyline;
}
 
开发者ID:Zlate87,项目名称:sample-transport-app,代码行数:21,代码来源:RouteMapService.java

示例7: testDecodePath

import com.google.maps.android.PolyUtil; //导入方法依赖的package包/类
public void testDecodePath() {
    List<LatLng> latLngs = PolyUtil.decode(TEST_LINE);

    int expectedLength = 21;
    Assert.assertEquals("Wrong length.", expectedLength, latLngs.size());

    LatLng lastPoint = latLngs.get(expectedLength - 1);
    expectNearNumber(37.76953, lastPoint.latitude, 1e-6);
    expectNearNumber(-122.41488, lastPoint.longitude, 1e-6);
}
 
开发者ID:runningcode,项目名称:CUMtd,代码行数:11,代码来源:PolyUtilTest.java

示例8: computeDrawingLength

import com.google.maps.android.PolyUtil; //导入方法依赖的package包/类
/**
 * Compute the length of the drawing in meters.
 *
 * @return the length of the drawing in meters.
 */
private double computeDrawingLength() {
    double length = 0d;
    for (String encodedPath : mEncodedPolylines) {
        final List<LatLng> path = PolyUtil.decode(encodedPath);
        length += SphericalUtil.computeLength(path);
    }
    return length;
}
 
开发者ID:tvbarthel,项目名称:SayItFromTheSky,代码行数:14,代码来源:Drawing.java

示例9: setUpMap

import com.google.maps.android.PolyUtil; //导入方法依赖的package包/类
private void setUpMap() {
    mRoute = PolyUtil.decode(ROUTE);

    // Create a polyline for the route.
    mMap.addPolyline(new PolylineOptions()
            .addAll(mRoute)
            .color(Color.HSVToColor(POLYLINE_ALPHA,
                    new float[] {
                            POLYLINE_HUE, POLYLINE_SATURATION, POLYLINE_VALUE
                    }))
            .width(POLYLINE_WIDTH));

    mMap.setOnCameraChangeListener(new GoogleMap.OnCameraChangeListener() {
        @Override
        public void onCameraChange(CameraPosition position) {
            mMap.setOnCameraChangeListener(null);
            
            // Move the camera to show the entire route.
            LatLngBounds.Builder builder = LatLngBounds.builder();
            for (LatLng coords : mRoute) {
                builder.include(coords);
            }
            mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(builder.build(), 100));
            
            mInitZoom = mMap.getCameraPosition().zoom;
            mInitPosition = mMap.getCameraPosition().target;
        }
    });
    
    mMap.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() {
        @Override
        public void onMapLoaded() {
            addDataToMap();
        }
    });
}
 
开发者ID:saxman,项目名称:maps-android-dataviz,代码行数:37,代码来源:MainActivity.java

示例10: startDemo

import com.google.maps.android.PolyUtil; //导入方法依赖的package包/类
@Override
protected void startDemo() {
    List<LatLng> decodedPath = PolyUtil.decode(LINE);

    getMap().addPolyline(new PolylineOptions().addAll(decodedPath));

    getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(-33.8256, 151.2395), 12));
}
 
开发者ID:googlemaps,项目名称:android-maps-utils,代码行数:9,代码来源:PolyDecodeDemoActivity.java

示例11: getPolyline

import com.google.maps.android.PolyUtil; //导入方法依赖的package包/类
public Iterable<LatLng> getPolyline() {
    return PolyUtil.decode(itinerary.polyline);
}
 
开发者ID:snigle,项目名称:corsaire,代码行数:4,代码来源:NavigationService.java

示例12: getPointList

import com.google.maps.android.PolyUtil; //导入方法依赖的package包/类
public List<LatLng> getPointList() {
    return PolyUtil.decode(rawPointList);
}
 
开发者ID:akexorcist,项目名称:Android-GoogleDirectionLibrary,代码行数:4,代码来源:RoutePolyline.java

示例13: testEncodePath

import com.google.maps.android.PolyUtil; //导入方法依赖的package包/类
public void testEncodePath() {
    List<LatLng> path = PolyUtil.decode(TEST_LINE);
    String encoded = PolyUtil.encode(path);
    Assert.assertEquals(TEST_LINE, encoded);
}
 
开发者ID:runningcode,项目名称:CUMtd,代码行数:6,代码来源:PolyUtilTest.java

示例14: toList

import com.google.maps.android.PolyUtil; //导入方法依赖的package包/类
public List<LatLng> toList() {
    return PolyUtil.decode(points);
}
 
开发者ID:mg6maciej,项目名称:warsjawa2013-android-squared-googled-preparation,代码行数:4,代码来源:EncodedPolyline.java

示例15: onMapReady

import com.google.maps.android.PolyUtil; //导入方法依赖的package包/类
@Override
public void onMapReady(GoogleMap googleMap) {

    contexto = (RutasActivity) getActivity();

    mMap = googleMap;

    mMap.getUiSettings().setZoomControlsEnabled(true);
    mMap.getUiSettings().setMyLocationButtonEnabled(true);

    mMap.getUiSettings().setMapToolbarEnabled(true);

    mMap.getUiSettings().setAllGesturesEnabled(false);

    mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(38.386058, -0.51001810), 17));

    Leg leg = contexto.getLegActual();

    final List<LatLng> listaPuntos = new ArrayList<>();

    LatLng origen = new LatLng(Double.parseDouble(leg.getStartLat()), Double.parseDouble(leg.getStartLng()));
    mMap.addMarker(new MarkerOptions().position(origen));

    listaPuntos.add(origen);

    LatLng destino = new LatLng(Double.parseDouble(leg.getEndLat()), Double.parseDouble(leg.getEndLng()));
    mMap.addMarker(new MarkerOptions().position(destino));

    listaPuntos.add(destino);


    if (listaPuntos != null && !listaPuntos.isEmpty()) {


        LatLngBounds.Builder ltb = new LatLngBounds.Builder();

        for (int i = 0; i < listaPuntos.size(); i++) {
            ltb.include(listaPuntos.get(i));
        }

        LatLngBounds bounds = ltb.build();


        mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 50));


    }

    //Obtener linea
    polyline = contexto.getPolyline();

    if (polyline != null) {
        List<LatLng> polDecode = PolyUtil.decode(polyline);

        PolylineOptions poly = new PolylineOptions();
        poly.addAll(polDecode);

        mMap.addPolyline(poly);
    }

}
 
开发者ID:alberapps,项目名称:tiempobus,代码行数:62,代码来源:RutaMapaFragment.java


注:本文中的com.google.maps.android.PolyUtil.decode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。