コード例 #1
0
    /** creates marker for tweet and its to map */
    private void addTweet(Tweet t) {
      if (t.getText() == null) {
        // ignore tweets without text
        return;
      }
      GeoCoordinate gc = t.getUserCoordinate();
      boolean addTweet = true;

      cleanOldest();
      if (map.getZoomLevel() > 0) {
        GeoBoundingBox gbb =
            new GeoBoundingBox(
                map.pixelToGeo(new Point(0, 0)),
                map.pixelToGeo(new Point(map.getWidth(), map.getHeight())));

        addTweet = gbb.contains(gc);
      }
      if (addTweet) {
        MapStandardMarker msm =
            mapFactory.createStandardMarker(gc, 100, "", MapStandardMarker.BALLOON);

        msm.setColor(MARKER_COLOR);
        map.addMapObject(msm);
        addedTweets.addData(msm, t);
        tweetAge.put(msm, new Long(t.getCreatedTime()));
        repaint();
      }
    }
コード例 #2
0
    /**
     * Adds marker to center of the screen and returns its coordinate
     *
     * @return coordinate added
     */
    private GeoCoordinate selectPosition() {
      Point center = new Point(map.getWidth() / 2, map.getHeight() / 2);
      GeoCoordinate gc = map.pixelToGeo(center);

      if (marker == null) {
        // create new marker
        marker = mapFactory.createStandardMarker(gc, 10, null, MapStandardMarker.BALLOON);
        map.addMapObject(marker);
      } else {
        // move existing marker
        marker.setCoordinate(gc);
      }
      return gc;
    }