public MyItem(double lat, double lng) { mPosition = new LatLng(lat, lng); mTitle = null; mSnippet = null; }
if (start.equals(end)) { return computeDistanceBetween(end, p); return computeDistanceBetween(p, end); LatLng sa = new LatLng(p.latitude - start.latitude, p.longitude - start.longitude); LatLng sb = new LatLng(u * (end.latitude - start.latitude), u * (end.longitude - start.longitude)); return computeDistanceBetween(sa, sb);
@Override public boolean equals(Object other) { if (!(other instanceof StaticCluster<?>)) { return false; } return ((StaticCluster<?>) other).mCenter.equals(mCenter) && ((StaticCluster<?>) other).mItems.equals(mItems); } }
/** * Returns true if the provided list of points is a closed polygon (i.e., the first and last * points are the same), and false if it is not * @param poly polyline or polygon * @return true if the provided list of points is a closed polygon (i.e., the first and last * points are the same), and false if it is not */ public static boolean isClosedPolygon(List<LatLng> poly) { LatLng firstPoint = poly.get(0); LatLng lastPoint = poly.get(poly.size()-1); return firstPoint.equals(lastPoint); }
public MyItem(double lat, double lng, String title, String snippet) { mPosition = new LatLng(lat, lng); mTitle = title; mSnippet = snippet; }
public LatLng toLatLng(com.google.maps.android.geometry.Point point) { final double x = point.x / mWorldWidth - 0.5; final double lng = x * 360; double y = .5 - (point.y / mWorldWidth); final double lat = 90 - Math.toDegrees(Math.atan(Math.exp(-y * 2 * Math.PI)) * 2); return new LatLng(lat, lng); } }
@JavascriptInterface public void getBoundsCallback( double neLat, double neLng, double swLat, double swLng) { final LatLngBounds bounds = new LatLngBounds(new LatLng(swLat, swLng), new LatLng(neLat, neLng)); handler.post(new Runnable() { @Override public void run() { onMapBoundsCallback.onMapBoundsReady(bounds); } }); }
/** * Given a set of four latLng coordinates, creates a LatLng Bound * * @param north North coordinate of the bounding box * @param south South coordinate of the bounding box * @param east East coordinate of the bounding box * @param west West coordinate of the bounding box */ private static LatLngBounds createLatLngBounds(Double north, Double south, Double east, Double west) { LatLng southWest = new LatLng(south, west); LatLng northEast = new LatLng(north, east); return new LatLngBounds(southWest, northEast); } }
private LatLng locationToLatLng(Location location) { return new LatLng(location.getLatitude(), location.getLongitude()); }
private ArrayList<LatLng> readItems(int resource) throws JSONException { ArrayList<LatLng> list = new ArrayList<LatLng>(); InputStream inputStream = getResources().openRawResource(resource); String json = new Scanner(inputStream).useDelimiter("\\A").next(); JSONArray array = new JSONArray(json); for (int i = 0; i < array.length(); i++) { JSONObject object = array.getJSONObject(i); double lat = object.getDouble("lat"); double lng = object.getDouble("lng"); list.add(new LatLng(lat, lng)); } return list; }
@Override public void run() { if (onMapMarkerDragListener != null) { onMapMarkerDragListener.onMapMarkerDrag(markerId, new LatLng(lat, lng)); } } });
@Override public void run() { if (onMapClickListener != null) { onMapClickListener.onMapClick(new LatLng(lat, lng)); } if (infoWindowView != null) { mLayout.removeView(infoWindowView); } } });
@Override public void run() { if (onMapMarkerDragListener != null) { onMapMarkerDragListener.onMapMarkerDragStart(markerId, new LatLng(lat, lng)); } } });
@Override public void run() { if (onMapMarkerDragListener != null) { onMapMarkerDragListener.onMapMarkerDragEnd(markerId, new LatLng(lat, lng)); } } });
public TestingItem(double lat, double lng) { mPosition = new LatLng(lat, lng); }
@Override public void onDataChange(DataSnapshot dataSnapshot) { Map<String, Object> td = (HashMap<String, Object>) dataSnapshot.getValue(); if (td==null)return; double lat = Double.parseDouble(td.get("lat").toString()); double lag = Double.parseDouble(td.get("lag").toString()); /** Make sure that the map has been initialised **/ sydney = new LatLng(lat, lag); LastDateOnline= td.get("LastOnlineDate").toString(); LoadMap(); }
/** * Convert a string coordinate from a string into a LatLngAlt object * * @param coordinateString coordinate string to convert from * @param separator separator to use when splitting coordinates * @return LatLngAlt object created from given coordinate string */ private static LatLngAlt convertToLatLngAlt(String coordinateString, String separator) { String[] coordinate = coordinateString.split(separator); Double lat = Double.parseDouble(coordinate[LATITUDE_INDEX]); Double lon = Double.parseDouble(coordinate[LONGITUDE_INDEX]); Double alt = (coordinate.length > 2) ? Double.parseDouble(coordinate[ALTITUDE_INDEX]) : null; LatLng latLng = new LatLng(lat, lon); return new LatLngAlt(latLng, alt); }
public LatLng getPosition() { JSONObject location = jsonData.optJSONObject(LOCATION); if (location != null) { if (location.has("latitude") && location.has("longitude")) { double latitude = location.optDouble("latitude"); double longitude = location.optDouble("longitude"); return new LatLng(latitude, longitude); } } return null; }
@Override public void onLocationChanged(Location location) { if (mapLocationListener != null) { mapLocationListener.onLocationChanged(location); LatLng latlng= new LatLng(location.getLatitude(), location.getLongitude()); CameraUpdate cu=CameraUpdateFactory.newLatLng(latlng); map.animateCamera(cu); } }
public LineString createSimpleLineString() { ArrayList<LatLng> coordinates = new ArrayList<LatLng>(); coordinates.add(new LatLng(95, 60)); coordinates.add(new LatLng(93, 57)); coordinates.add(new LatLng(95, 55)); coordinates.add(new LatLng(95, 53)); coordinates.add(new LatLng(91, 54)); coordinates.add(new LatLng(86, 56)); return new LineString(coordinates); }