Search in sources :

Example 16 with Coord

use of com.codename1.maps.Coord in project CodenameOne by codenameone.

the class Tile method pointPosition.

/**
 * Returns the x, y point of the given coordinate relative to this tile
 * @param point a coordinate to translate to x, y
 * @return a Point object relative to this tile
 */
public Point pointPosition(Coord point) {
    int x = position(dimension.getWidth(), point.getLongitude(), bbox.getSouthWest().getLongitude(), bbox.getNorthEast().getLongitude());
    int y = position(dimension.getHeight(), point.getLatitude(), bbox.getSouthWest().getLatitude(), bbox.getNorthEast().getLatitude());
    // 
    return new Point(x, dimension.getHeight() - y);
}
Also used : Point(com.codename1.ui.geom.Point) Point(com.codename1.ui.geom.Point)

Example 17 with Coord

use of com.codename1.maps.Coord in project CodenameOne by codenameone.

the class LinesLayer method paint.

/**
 * {@inheritDoc}
 */
public void paint(Graphics g, Tile screenTile) {
    g.setColor(_lineColor);
    g.setAntiAliased(true);
    int segmentsNo = _lineSegments.size();
    for (int i = 0; i < segmentsNo; i++) {
        paintSegment(g, (Coord[]) _lineSegments.elementAt(i), screenTile);
    }
}
Also used : Coord(com.codename1.maps.Coord) Point(com.codename1.ui.geom.Point)

Example 18 with Coord

use of com.codename1.maps.Coord in project CodenameOne by codenameone.

the class LinesLayer method boundingBox.

/**
 * {@inheritDoc}
 */
public BoundingBox boundingBox() {
    BoundingBox bbox = null;
    for (int i = 0; i < _lineSegments.size(); i++) {
        Coord[] coords = (Coord[]) _lineSegments.elementAt(i);
        BoundingBox cBbox = BoundingBox.create(coords);
        if (bbox == null) {
            bbox = cBbox;
        } else {
            bbox = bbox.extend(cBbox);
        }
    }
    return bbox;
}
Also used : Coord(com.codename1.maps.Coord) BoundingBox(com.codename1.maps.BoundingBox) Point(com.codename1.ui.geom.Point)

Example 19 with Coord

use of com.codename1.maps.Coord in project CodenameOne by codenameone.

the class PointsLayer method removePoint.

/**
 * Removes a point from the PointsLayer
 *
 * @param point to remove from the PointsLayer
 */
public void removePoint(PointLayer point) {
    if (!point.isProjected()) {
        Coord c = getProjection().fromWGS84(point);
        point.setLatitude(c.getLatitude());
        point.setLongitude(c.getLongitude());
        point.setProjected(true);
    }
    points.removeElement(point);
}
Also used : Coord(com.codename1.maps.Coord)

Example 20 with Coord

use of com.codename1.maps.Coord in project CodenameOne by codenameone.

the class MapProvider method maxZoomFor.

/**
 * Returns the maximum zoom of a specific Tile.
 * @param tile tile to check the max zoom
 * @return the max zoom of the tile
 */
public int maxZoomFor(Tile tile) {
    int zoom;
    int height = tile.dimension().getHeight();
    int width = tile.dimension().getWidth();
    double latitude = tile.getBoundingBox().latitudeDifference();
    double longitude = tile.getBoundingBox().longitudeDifference();
    for (zoom = maxZoomLevel(); zoom > 0; zoom--) {
        Coord scale = scale(zoom);
        if ((scale.getLatitude() * height) > latitude && (scale.getLongitude() * width) > longitude) {
            break;
        }
    }
    return zoom;
}
Also used : Coord(com.codename1.maps.Coord)

Aggregations

Coord (com.codename1.maps.Coord)19 Point (com.codename1.ui.geom.Point)14 BoundingBox (com.codename1.maps.BoundingBox)7 Component (com.codename1.ui.Component)3 EncodedImage (com.codename1.ui.EncodedImage)3 ActionEvent (com.codename1.ui.events.ActionEvent)3 ActionListener (com.codename1.ui.events.ActionListener)3 Dimension (com.codename1.ui.geom.Dimension)3 MapObject (com.codename1.googlemaps.MapContainer.MapObject)2 Mercator (com.codename1.maps.Mercator)2 PointsLayer (com.codename1.maps.layers.PointsLayer)2 Button (com.codename1.ui.Button)2 Image (com.codename1.ui.Image)2 ArrayList (java.util.ArrayList)2 FloatingActionButton (com.codename1.components.FloatingActionButton)1 InteractionDialog (com.codename1.components.InteractionDialog)1 ToastBar (com.codename1.components.ToastBar)1 MapContainer (com.codename1.googlemaps.MapContainer)1 MarkerOptions (com.codename1.googlemaps.MapContainer.MarkerOptions)1 Util (com.codename1.io.Util)1