com.esri.core.symbol.SimpleMarkerSymbol Java Examples

The following examples show how to use com.esri.core.symbol.SimpleMarkerSymbol. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DemoTheatreApp.java    From arcgis-runtime-demo-java with Apache License 2.0 6 votes vote down vote up
private void highlightGeometry(Point point) {
  if (point == null) {
    return;
  }

  graphicsLayer.removeAll();
  graphicsLayer.addGraphic(
    new Graphic(point, new SimpleMarkerSymbol(Color.CYAN, 20, SimpleMarkerSymbol.Style.CIRCLE)));
  
  // -----------------------------------------------------------------------------------------
  // Zoom to the highlighted graphic
  // -----------------------------------------------------------------------------------------
  Geometry geometryForZoom = GeometryEngine.buffer(
    point, 
    map.getSpatialReference(), 
    map.getFullExtent().getWidth() * 0.10, 
    map.getSpatialReference().getUnit());
  map.zoomTo(geometryForZoom);
}
 
Example #2
Source File: ClusterApp.java    From arcgis-runtime-demo-java with Apache License 2.0 6 votes vote down vote up
/**
 * Adds graphics symbolized with SimpleMarkerSymbols.
 * @param graphicsLayer
 */
private void addSimpleMarkerGraphics(GraphicsLayer graphicsLayer, Envelope bounds) {
  SimpleMarkerSymbol symbol = new SimpleMarkerSymbol(Color.RED, 16, Style.CIRCLE);
  double xmin = bounds.getXMin();
  double xmax = bounds.getXMax();
  double xrand;
  double ymin = bounds.getYMin();
  double ymax = bounds.getYMax();
  double yrand;
  for (int i = 0; i < 1000; i++) {
    xrand = xmin + (int) (Math.random() * ((xmax - xmin) + 1));
    yrand = ymin + (int) (Math.random() * ((ymax - ymin) + 1));
    Point point = new Point(xrand, yrand);
    graphicsLayer.addGraphic(new Graphic(point, symbol));
  }
  
}
 
Example #3
Source File: RasterAnalysisHelper.java    From arcgis-runtime-demos-android with Apache License 2.0 5 votes vote down vote up
private void changeObserver(Point mapPoint) {
  // clear any graphics
  mGraphicsLayer.removeAll();
  // create a graphic to represent observer position
  Graphic graphic = new Graphic(mapPoint, new SimpleMarkerSymbol(
      Color.YELLOW, 20, SimpleMarkerSymbol.STYLE.CROSS));
  // add graphic to map
  mGraphicsLayer.addGraphic(graphic);
  //set observer on viewshed
  mTask.setObserver(mapPoint);
}
 
Example #4
Source File: DemoTheatreAppImproved.java    From arcgis-runtime-demo-java with Apache License 2.0 5 votes vote down vote up
private void highlightGeometry(Point point) {
  if (point == null) {
    return;
  }

  graphicsLayer.removeAll();
  graphicsLayer.addGraphic(
    new Graphic(point, new SimpleMarkerSymbol(Color.CYAN, 20, SimpleMarkerSymbol.Style.CIRCLE)));
  
  // -----------------------------------------------------------------------------------------
  // Zoom to the highlighted graphic
  // -----------------------------------------------------------------------------------------
  // from base map's information, zoom to a resolution so that city is in focus
  map.zoomToResolution(0.02197265625, point);
}
 
Example #5
Source File: DemoTheatreAppImproved.java    From arcgis-runtime-demo-java with Apache License 2.0 5 votes vote down vote up
private void handleAddGraphic(MouseEvent mapEvent) {
  Point p = jMap.toMapPoint(mapEvent.getPoint().x, mapEvent.getPoint().y);
  // Tip: use the right symbol for geometry
  SimpleMarkerSymbol s = new SimpleMarkerSymbol(Color.RED, 14, Style.CROSS);
  //SimpleLineSymbol s = new SimpleLineSymbol(Color.RED, 10);
  graphicsLayer.addGraphic(new Graphic(p, s));  
}
 
Example #6
Source File: ParticleGraphicsEllipseApp.java    From arcgis-runtime-demo-java with Apache License 2.0 5 votes vote down vote up
private void addEllipses(int numberOfEllipses) {
  SimpleMarkerSymbol[] symbols = {symbol4, symbol3, symbol2, symbol1};
  // some values that works well
  int majorAxisLength = 4612483;
  int minorAxisLength = 1843676;

  centerPoint = new Point(500000-5000000, 500000 + 3000000);
  centerGraphicsLayer.addGraphic(new Graphic(centerPoint, null));

  for (int i = 0; i < numberOfEllipses; i++) {
    Point center = new Point(random.nextInt(500000)-5000000, random.nextInt(500000) + 3000000);
    int majorAxisDirection = random.nextInt(60);
    LinearUnit unit = new LinearUnit(LinearUnit.Code.METER);

    Geometry ellipse = GeometryEngine.geodesicEllipse(center, map.getSpatialReference(), majorAxisLength, minorAxisLength,
        majorAxisDirection, pointCount, unit, Geometry.Type.MULTIPOINT);

    if (ellipse instanceof MultiPoint) {
      SimpleMarkerSymbol symbol = symbols[i%4];
      MultiPoint mp = (MultiPoint) ellipse;
      Ellipse currentEllipse = new Ellipse(mp); 
      ellipses.add(currentEllipse);
      int j = 0;
      while (j < mp.getPointCount()) {
        if (j%8==0) {
          Point point = mp.getPoint(j);
          int id = ellipseGraphicsLayer.addGraphic(new Graphic(point, symbol));
          currentEllipse.addPoint(id, j);
        }
        j++;
      }
    }
  }
}
 
Example #7
Source File: ClusterLayer.java    From arcgis-runtime-demo-java with Apache License 2.0 5 votes vote down vote up
private Symbol createPointSymbol(Color color, int num) {
  if (num < 2) {
    Symbol sms = new SimpleMarkerSymbol(color, 16, Style.CIRCLE);
    return sms;
  }
  List<Symbol> symbols = new ArrayList<Symbol>();
  symbols.add(new SimpleMarkerSymbol(color, 32, Style.CIRCLE));
  symbols.add(new TextSymbol(14, "" + num, Color.WHITE));
  CompositeSymbol cs = new CompositeSymbol(symbols);
  return cs;
}
 
Example #8
Source File: ParticleGraphicsEllipseApp.java    From arcgis-runtime-demo-java with Apache License 2.0 5 votes vote down vote up
private void addEllipses(int numberOfEllipses) {
  SimpleMarkerSymbol[] symbols = {symbol4, symbol3, symbol2, symbol1};
  // some values that works well
  int majorAxisLength = 4612483;
  int minorAxisLength = 1843676;

  centerPoint = new Point(500000-5000000, 500000 + 3000000);
  centerGraphicsLayer.addGraphic(new Graphic(centerPoint, null));

  for (int i = 0; i < numberOfEllipses; i++) {
    Point center = new Point(random.nextInt(500000)-5000000, random.nextInt(500000) + 3000000);
    int majorAxisDirection = random.nextInt(60);
    LinearUnit unit = new LinearUnit(LinearUnit.Code.METER);

    Geometry ellipse = GeometryEngine.geodesicEllipse(center, map.getSpatialReference(), majorAxisLength, minorAxisLength,
        majorAxisDirection, pointCount, unit, Geometry.Type.MULTIPOINT);

    if (ellipse instanceof MultiPoint) {
      SimpleMarkerSymbol symbol = symbols[i%4];
      MultiPoint mp = (MultiPoint) ellipse;
      Ellipse currentEllipse = new Ellipse(mp); 
      ellipses.add(currentEllipse);
      int j = 0;
      while (j < mp.getPointCount()) {
        if (j%8==0) {
          Point point = mp.getPoint(j);
          int id = ellipseGraphicsLayer.addGraphic(new Graphic(point, symbol));
          currentEllipse.addPoint(id, j);
        }
        j++;
      }
    }
  }
}
 
Example #9
Source File: GPSTesterActivityController.java    From android-gps-test-tool with Apache License 2.0 5 votes vote down vote up
/**
 * Helper method that uses latitude/longitude points to programmatically 
 * draw a <code>SimpleMarkerSymbol</code> and adds the <code>Graphic</code> to map.
 * @param latitude
 * @param longitude
 * @param attributes
 * @param style You defined the style via the Enum <code>SimpleMarkerSymbol.STYLE</code>
 */
public static void addGraphicLatLon(double latitude, double longitude, Map<String, Object> attributes, 
		SimpleMarkerSymbol.STYLE style,int color,int size, GraphicsLayer graphicsLayer, MapView map){
	
	Point latlon = new Point(longitude,latitude);		
	
	//Convert latlon Point to mercator map point.
	Point point = (Point)GeometryEngine.project(latlon,SpatialReference.create(4326), map.getSpatialReference());		
	
	//Set market's color, size and style. You can customize these as you see fit
	SimpleMarkerSymbol symbol = new SimpleMarkerSymbol(color,size, style);			
	Graphic graphic = new Graphic(point, symbol,attributes);
	graphicsLayer.addGraphic(graphic);
}
 
Example #10
Source File: MainActivity.java    From arcgis-runtime-demos-android with Apache License 2.0 4 votes vote down vote up
@Override
public boolean onSingleTap(MotionEvent point) {

    if (mLocator == null) {
        Log.d(TAG, "Locator uninitialized : " + true);
        return super.onSingleTap(point);
    }
    // Add a graphic to the screen for the touch event
    Point mapPoint = mMapView.toMapPoint(point.getX(), point.getY());
    Graphic graphic = new Graphic(mapPoint, new SimpleMarkerSymbol(Color.BLUE, 10, STYLE.DIAMOND));
    mGraphicsLayer.addGraphic(graphic);

    String stopAddress = "";
    try {
        // Attempt to reverse geocode the point.
        // Our input and output spatial reference will
        // be the same as the map.
        SpatialReference mapRef = mMapView.getSpatialReference();
        LocatorReverseGeocodeResult result = mLocator.reverseGeocode(mapPoint, 50, mapRef, mapRef);

        // Construct a nicely formatted address from the results
        StringBuilder address = new StringBuilder();
        if (result != null && result.getAddressFields() != null) {
            Map<String, String> addressFields = result.getAddressFields();
            address.append(String.format("%s\n%s, %s %s", addressFields.get("Street"), addressFields.get("City"),
                    addressFields.get("State"), addressFields.get("ZIP")));
        }

        // Show the results of the reverse geocoding in
        // the map's callout.
        stopAddress = address.toString();
        showCallout(stopAddress, mapPoint);

    } catch (Exception e) {
        Log.v("Reverse Geocode", e.getMessage());
    }

    // Add the touch event as a stop
    StopGraphic stop = new StopGraphic(graphic);
    stop.setName(stopAddress.toString());
    mStops.addFeature(stop);

    return true;
}
 
Example #11
Source File: SampleController.java    From arcgis-runtime-demo-java with Apache License 2.0 4 votes vote down vote up
@FXML
private void selectRedSymbol(ActionEvent event) {
 symbol = new SimpleMarkerSymbol(Color.RED, 12, Style.CIRCLE);
 mapMode = MapMode.ADD_GRAPHIC;
}
 
Example #12
Source File: SampleController.java    From arcgis-runtime-demo-java with Apache License 2.0 4 votes vote down vote up
@FXML
private void selectGreenSymbol(ActionEvent event) {
 symbol = new SimpleMarkerSymbol(Color.GREEN, 12, Style.CIRCLE);
 mapMode = MapMode.ADD_GRAPHIC;
}
 
Example #13
Source File: SampleController.java    From arcgis-runtime-demo-java with Apache License 2.0 4 votes vote down vote up
@FXML
private void selectBlueSymbol(ActionEvent event) {
 symbol = new SimpleMarkerSymbol(Color.BLUE, 12, Style.CIRCLE);
 mapMode = MapMode.ADD_GRAPHIC;
}
 
Example #14
Source File: GPSTesterActivityController.java    From android-gps-test-tool with Apache License 2.0 4 votes vote down vote up
private static void writeResultToTable(
			Location location,
			LocationManager locationManager,
			String elapsedTimeGPSProvider,
			Boolean isNetworkAvailable){
		
    	_gpsLatitude = location.getLatitude();
    	_gpsLongitude = location.getLongitude();
    	_gpsAccuracy = location.getAccuracy();  
    	final double speed = location.getSpeed();
    	final double altitude = location.getAltitude();

    	String bestAvailableText = "";
    	
		boolean networkProviderEnabled = false; 	
		boolean gpsProviderEnabled = false;
		
		try{
			networkProviderEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
			gpsProviderEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
		}
		catch(Exception exc){
			Log.d("GPSTester","WriteResultToTable(): " + exc.getMessage());
		}

    	if(_networkAccuracy > _gpsAccuracy && _gpsAccuracy > 0.0 && gpsProviderEnabled == true){
    		_bestAvailableType = BestAvailableType.GPS;
    		bestAvailableText = "<b><font color='yellow'>Best Accuracy</font> = <font color='red'>GPS</b></font>" +
    				"<br><b>GPS Accuracy:</b> " + DECIMAL_FORMAT_4.format(_gpsAccuracy) + " meters" +
    				"<br><b>GPS Lat/Lon:</b> " + _gpsLatitude + ", " + _gpsLongitude;
    	}  	
    	else if(_gpsAccuracy > _networkAccuracy && _networkAccuracy > 0.0 && networkProviderEnabled == true){
    		_bestAvailableType = BestAvailableType.NETWORK;	    		
    		bestAvailableText = "<b><font color='yellow'><b><font color='yellow'>Best Accuracy</font> = <font color='red'>Network</b></font></b></font>" +
    				"<br><b>Network Accuracy:<b/> " + DECIMAL_FORMAT_4.format(_networkAccuracy) + " meters" +
    				"<br><b>Network Lat/Lon:<b/> " + _networkLatitude + ", " + _networkLongitude;
    	}
    	else if(_gpsAccuracy == 0.0 && _networkAccuracy > 0.0 && networkProviderEnabled == true){
    		_bestAvailableType = BestAvailableType.NETWORK;	    		
    		bestAvailableText = "<b><font color='yellow'><b><font color='yellow'>Best Accuracy</font> = <font color='red'>Network</b></font></b></font>" +
    				"<br><b>Network Accuracy:<b/> " + DECIMAL_FORMAT_4.format(_networkAccuracy) + " meters" +
    				"<br><b>Network Lat/Lon:<b/> " + _networkLatitude + ", " + _networkLongitude;    		
    	}
    	else if(_networkAccuracy == 0.0 && _gpsAccuracy > 0.0 && gpsProviderEnabled == true){
    		_bestAvailableType = BestAvailableType.GPS;
    		bestAvailableText = "<b><font color='yellow'>Best Accuracy</font> = <font color='red'>GPS</b></font>" +
    				"<br><b>GPS Accuracy:</b> " + DECIMAL_FORMAT_4.format(_gpsAccuracy) + " meters" +
    				"<br><b>GPS Lat/Lon:</b> " + _gpsLatitude + ", " + _gpsLongitude;    		
    	}
    	else{
    		_bestAvailableType = BestAvailableType.NULL;
    		bestAvailableText = "<b><font color='yellow'>Best Accuracy = N/A</b></font>" + 
    				"<br><b>Lat/Lon:</b> N/A" +  
    				"<br><b>Accuracy:</b> N/A";	    		
    	}
    	
	  	setBestAvailableImageView(_bestAvailableType);
		
		String elapsedTimeSinceLastGPS = _elapsedTimer.calculateTimeDifference(_initialGPSTime, _elapsedTimer.getElapsedtime());			  	
    	_initialGPSTime = _elapsedTimer.getElapsedtime();		
    	
	  	final String gpsLocationText = "<b><font color='yellow'>GPS Provider</b></font>" +
    		  	"<br><b>Timestamp:</b> " + _elapsedTimer.convertMillisToMDYHMSS(location.getTime()) +
				"<br><b>1st update elapsed time:</b> " + elapsedTimeGPSProvider +
			  	"<br><b>Since last update:</b> " + elapsedTimeSinceLastGPS +
		  		"<br><b>Lat/Lon:</b> " + _gpsLatitude + ", " + _gpsLongitude +
		  		"<br><b>DMSS:</b> " + 
		  			Location.convert(_gpsLatitude, Location.FORMAT_SECONDS) + ", " +					  			
		  			Location.convert(_gpsLongitude, Location.FORMAT_SECONDS) +
		  		"<br><b>Accuracy:</b> " + DECIMAL_FORMAT_4.format(_gpsAccuracy) + " meters" +
		  		"<br><b>Speed:</b> " + DECIMAL_FORMAT.format((speed * 2.2369)) + " mph" + ", " +
		  		DECIMAL_FORMAT.format(((speed * 3600)/1000)) + " km/h" +
		  		"<br><b>Altitude:</b> " + DECIMAL_FORMAT.format(altitude) + " m, " +
		  		DECIMAL_FORMAT.format(altitude * 3.2808) + " ft" +
		  		"<br><b>Bearing:</b> " + location.getBearing() + " deg";				  	
			  	
    	
	  	_gpsLocationTextView.setText(Html.fromHtml(gpsLocationText));	  	
    	_bestAvailableInfoTextView.setText(Html.fromHtml(bestAvailableText));
    	    	
    	//If true then we can draw on the map. Offline maps not available in this version
    	if(isNetworkAvailable == true){
			final int redMapGraphicSize = Integer.valueOf(_preferences.getString("pref_key_gpsGraphicSize", "10"));    	
	    	
	    	// Called when a new location is found by the network location provider.
	    	if(_preferences.getBoolean("pref_key_centerOnGPSCoords", true) == true){
	    		_map.centerAt(_gpsLatitude, _gpsLongitude, true);
	    	}
	    	if(_preferences.getBoolean("pref_key_accumulateMapPoints", true) == false){
//	    		_map.clearPointsGraphicLayer();
	    		_graphicsLayer.removeAll();
	    	}
	    	
	    	addGraphicLatLon(_gpsLatitude, _gpsLongitude, null, SimpleMarkerSymbol.STYLE.CIRCLE,Color.RED,redMapGraphicSize,_graphicsLayer,_map);
    	}
	}