use of com.google.android.libraries.maps.model.PolylineOptions in project google-maps by capacitor-community.
the class CapacitorGoogleMaps method addPolyline.
@PluginMethod()
public void addPolyline(final PluginCall call) {
final JSArray points = call.getArray("points", new JSArray());
getBridge().executeOnMainThread(new Runnable() {
@Override
public void run() {
PolylineOptions polylineOptions = new PolylineOptions();
for (int i = 0; i < points.length(); i++) {
try {
JSONObject point = points.getJSONObject(i);
LatLng latLng = new LatLng(point.getDouble("latitude"), point.getDouble("longitude"));
polylineOptions.add(latLng);
} catch (JSONException e) {
e.printStackTrace();
}
}
googleMap.addPolyline(polylineOptions);
call.resolve();
}
});
}
use of com.google.android.libraries.maps.model.PolylineOptions in project android-maps-utils by googlemaps.
the class DistanceDemoActivity method startDemo.
@Override
protected void startDemo(boolean isRestore) {
mTextView = findViewById(R.id.textView);
if (!isRestore) {
getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(-33.8256, 151.2395), 10));
}
getMap().setOnMarkerDragListener(this);
mMarkerA = getMap().addMarker(new MarkerOptions().position(new LatLng(-33.9046, 151.155)).draggable(true));
mMarkerB = getMap().addMarker(new MarkerOptions().position(new LatLng(-33.8291, 151.248)).draggable(true));
mPolyline = getMap().addPolyline(new PolylineOptions().geodesic(true));
Toast.makeText(this, "Drag the markers!", Toast.LENGTH_LONG).show();
showDistance();
}
use of com.google.android.libraries.maps.model.PolylineOptions in project android-samples by googlemaps.
the class PolylineDemoActivity method onMapReady.
@Override
public void onMapReady(GoogleMap map) {
// For accessibility mode. Ideally this string would be localised.
map.setContentDescription("Google Map with polylines.");
// Non-loop polyline that goes past Australian cities. Added before sydneyPolyline and would
// normally be underneath, but increase Z-Index so that this line is on top.
australiaPolyline = map.addPolyline(new PolylineOptions().add(PERTH, ADELAIDE, SYDNEY, MELBOURNE).pattern(Arrays.asList(new Dot(), new Gap(20.0f))).color(Color.MAGENTA).zIndex(1));
// Geodesic polyline that goes around the world.
worldPolyline = map.addPolyline(new PolylineOptions().add(LONDON, AUCKLAND, LOS_ANGELES, NEW_YORK, LONDON).width(5).color(Color.BLUE).geodesic(true).clickable(true));
// Loop polyline centered at Sydney.
int radius = 4;
sydneyPolyline = map.addPolyline(new PolylineOptions().add(new LatLng(SYDNEY.latitude + radius, SYDNEY.longitude + radius)).add(new LatLng(SYDNEY.latitude + radius, SYDNEY.longitude - radius)).add(new LatLng(SYDNEY.latitude - radius, SYDNEY.longitude - radius)).add(new LatLng(SYDNEY.latitude - radius, SYDNEY.longitude)).add(new LatLng(SYDNEY.latitude - radius, SYDNEY.longitude + radius)).add(new LatLng(SYDNEY.latitude + radius, SYDNEY.longitude + radius)).pattern(Arrays.asList(new Dash(45.0f), new Gap(10.0f))).color(Color.RED).width(5).clickable(true));
// Create Melbourne polyline to show layering of polylines with same Z-Index. This is added
// second so it will be layered on top of the Sydney polyline (both have Z-Index == 0).
melbournePolyline = map.addPolyline(new PolylineOptions().add(new LatLng(MELBOURNE.latitude + radius, MELBOURNE.longitude + radius)).add(new LatLng(MELBOURNE.latitude + radius, MELBOURNE.longitude - radius)).add(new LatLng(MELBOURNE.latitude - radius, MELBOURNE.longitude - radius)).add(new LatLng(MELBOURNE.latitude - radius, MELBOURNE.longitude)).add(new LatLng(MELBOURNE.latitude - radius, MELBOURNE.longitude + radius)).add(new LatLng(MELBOURNE.latitude + radius, MELBOURNE.longitude + radius)).color(Color.GREEN).width(5).clickable(true));
map.moveCamera(CameraUpdateFactory.newLatLng(SYDNEY));
selectedPolyline = australiaPolyline;
polylineRadio.check(R.id.polyline_radio_australia);
pager.addOnPageChangeListener(this);
polylineRadio.setOnCheckedChangeListener(this);
map.setOnPolylineClickListener(this);
}
use of com.google.android.libraries.maps.model.PolylineOptions in project android-samples by googlemaps.
the class LiteDemoActivity method addPolyObjects.
/**
* Add a Polyline and a Polygon to the map.
* The Polyline connects Melbourne, Adelaide and Perth. The Polygon is located in the Northern
* Territory (Australia).
*/
private void addPolyObjects() {
map.addPolyline((new PolylineOptions()).add(MELBOURNE, ADELAIDE, PERTH).color(Color.GREEN).width(5f));
map.addPolygon(new PolygonOptions().add(POLYGON).fillColor(Color.CYAN).strokeColor(Color.BLUE).strokeWidth(5));
}
use of com.google.android.libraries.maps.model.PolylineOptions in project android-samples by googlemaps.
the class TagsDemoActivity method addObjectsToMap.
private void addObjectsToMap() {
// A circle centered on Adelaide.
mAdelaideCircle = mMap.addCircle(new CircleOptions().center(ADELAIDE).radius(500000).fillColor(Color.argb(150, 66, 173, 244)).strokeColor(Color.rgb(66, 173, 244)).clickable(true));
mAdelaideCircle.setTag(new CustomTag("Adelaide circle"));
// A ground overlay at Sydney.
mSydneyGroundOverlay = mMap.addGroundOverlay(new GroundOverlayOptions().image(BitmapDescriptorFactory.fromResource(R.drawable.harbour_bridge)).position(SYDNEY, 700000).clickable(true));
mSydneyGroundOverlay.setTag(new CustomTag("Sydney ground overlay"));
// A marker at Hobart.
mHobartMarker = mMap.addMarker(new MarkerOptions().position(HOBART));
mHobartMarker.setTag(new CustomTag("Hobart marker"));
// A polygon centered at Darwin.
mDarwinPolygon = mMap.addPolygon(new PolygonOptions().add(new LatLng(DARWIN.latitude + 3, DARWIN.longitude - 3), new LatLng(DARWIN.latitude + 3, DARWIN.longitude + 3), new LatLng(DARWIN.latitude - 3, DARWIN.longitude + 3), new LatLng(DARWIN.latitude - 3, DARWIN.longitude - 3)).fillColor(Color.argb(150, 34, 173, 24)).strokeColor(Color.rgb(34, 173, 24)).clickable(true));
mDarwinPolygon.setTag(new CustomTag("Darwin polygon"));
// A polyline from Perth to Brisbane.
mPolyline = mMap.addPolyline(new PolylineOptions().add(PERTH, BRISBANE).color(Color.rgb(103, 24, 173)).width(30).clickable(true));
mPolyline.setTag(new CustomTag("Perth to Brisbane polyline"));
}
Aggregations