@SuppressWarnings("rawtypes")
  private void setPosition() {
    Coordinates coor;
    try {
      coor = GeoCoder.getGeoCoordinates(company.getAddress());

      double latitude = Double.parseDouble(coor.getLatitude());
      double longitude = Double.parseDouble(coor.getLongitude());
      position = new GeoPosition(latitude, longitude);
      jXMapKit.setAddressLocation(position);

      Set<Waypoint> waypoints = new HashSet<Waypoint>();
      waypoints.add(new Waypoint(latitude, longitude));

      WaypointPainter<?> painter = new WaypointPainter();
      painter.setWaypoints(waypoints);
      //	        painter.setRenderer(new WaypointRenderer() {
      //	            public boolean paintWaypoint(Graphics2D g, JXMapViewer map, Waypoint wp) {
      //	                g.setColor(Color.RED);
      //	                g.drawLine(-5,-5,+5,+5);
      //	                g.drawLine(-5,+5,+5,-5);
      //	                return true;
      //	            }
      //	        });

      jXMapKit.getMainMap().setOverlayPainter(painter);
      jXMapKit.getMainMap().setZoom(2);
      jXMapKit.setAddressLocationShown(true);
      jXMapKit.setCenterPosition(position);
      jXMapKit.setDataProviderCreditShown(true);
    } catch (NonExistentAddressException e) {
      JOptionPane.showMessageDialog(
          this,
          e.getMessage(),
          ApplicationInternationalization.getString("Error"),
          JOptionPane.ERROR_MESSAGE);
    } catch (WSResponseException e) {
      JOptionPane.showMessageDialog(
          this,
          e.getMessage(),
          ApplicationInternationalization.getString("Error"),
          JOptionPane.ERROR_MESSAGE);
    } catch (IOException e) {
      JOptionPane.showMessageDialog(
          this,
          e.getMessage(),
          ApplicationInternationalization.getString("Error"),
          JOptionPane.ERROR_MESSAGE);
    } catch (JDOMException e) {
      JOptionPane.showMessageDialog(
          this,
          e.getMessage(),
          ApplicationInternationalization.getString("Error"),
          JOptionPane.ERROR_MESSAGE);
    }
  }
Beispiel #2
0
 public boolean findItem(JXMapKit map, Point2D pt) {
   GeoPosition gp = pos.getPoint();
   Point2D pt1 = map.getMainMap().getTileFactory().geoToPixel(gp, map.getMainMap().getZoom());
   return pt1.distance(pt) < 20;
 }