POST
|
I found that you shall use new Uri("ms-appx:///Assets/MapPinIcon-30.png") on Windows Phone instead of new Uri(pack://application:,,,/RouteDisplayer;component/Assets/MapPinIcon-30.png). It would be nice if the example https://developers.arcgis.com/net/sample-code/MarkerSymbols/http:// was updated with what changes you need to do for Windows Phone instead of just say: Available for Desktop, Store, Phone It might save some time for others in the future.
... View more
03-27-2015
04:41 AM
|
0
|
0
|
313
|
POST
|
Im trying to add pushpins on a map. I tried: var pushPinSymbol = new PictureMarkerSymbol() { Width = 30, Height = 30, XOffset = 0, YOffset = 25 };
pushPinSymbol.SetSourceAsync(new Uri("pack://application:,,,/RouteDisplayer;component/Assets/MapPinIcon-30.png")); and gets an invalid port specified error. Is there another way I'm supposed to add an image to the symbol?
... View more
03-27-2015
03:47 AM
|
0
|
1
|
3837
|
POST
|
I'm using the Runtime for .NET. I can deploy it now, just have to find out why the map is not showing Thanks for the quick response
... View more
03-17-2015
07:52 AM
|
0
|
1
|
396
|
POST
|
I must have missed something. I have a Nokia 630 that I try to use as device for the .NET Windows Phone tutorials. But when I tried to deploy the app I got a DEP3311 error. I have to set solution platforms to ARM but Arcgis Runtime only works with x86. And when I search the net for solutions I only find answers like : You can't build x86 app for the store, as it doesn't accept x86 apps. That's because there are no Windows Phones running on x86 CPUs right now So how do you guys solve this?
... View more
03-17-2015
07:33 AM
|
0
|
3
|
3829
|
POST
|
I try show in your code instead: MapView mMapView = null; // The basemap switching menu items. MenuItem mStreetsMenuItem = null; MenuItem mTopoMenuItem = null; MenuItem mGrayMenuItem = null; MenuItem mOceansMenuItem = null; // Create MapOptions for each type of basemap. final MapOptions mTopoBasemap = new MapOptions(MapOptions.MapType.TOPO); final MapOptions mStreetsBasemap = new MapOptions(MapOptions.MapType.STREETS); final MapOptions mGrayBasemap = new MapOptions(MapOptions.MapType.GRAY); final MapOptions mOceansBasemap = new MapOptions(MapOptions.MapType.OCEANS); // Here is the field for saving the maps spatial reference private SpatialReference mapSpatialReference; ArcGISTiledMapServiceLayer tms = new ArcGISTiledMapServiceLayer("http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"); // The current map extent, use to set the extent of the map after switching basemaps. Polygon mCurrentMapExtent = null; GraphicsLayer mLocationLayer; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_gis2); // Retrieve the map and initial extent from XML layout mMapView = (MapView) findViewById(R.id.map); mLocationLayer = new GraphicsLayer(); mMapView.addLayer(tms); // Set the Esri logo to be visible, and enable map to wrap around date line. mMapView.setEsriLogoVisible(false); mMapView.enableWrapAround(true); // Set a listener for map status changes; this will be called when switching basemaps. mMapView.setOnStatusChangedListener(new OnStatusChangedListener() { private static final long serialVersionUID = 1L; @Override public void onStatusChanged(Object source, STATUS status) { // Set the map extent once the map has been initialized, and the basemap is added // or changed; this will be indicated by the layer initialization of the basemap layer. As there is only // a single layer, there is no need to check the source object. if ((source == mMapView) && (status == STATUS.INITIALIZED)) { boolean mIsMapLoaded = true; mapSpatialReference = mMapView.getSpatialReference(); // if you need to check the maps spatial reference before you draw you do like this to ensure //you don't draw before the map is initialized writePolyline(); } } }); } public void writePolyline(){ SimpleLineSymbol lineSymbol = new SimpleLineSymbol(Color.GREEN, 3, SimpleLineSymbol.STYLE.DASH); Polyline lineGeometry = new Polyline(); lineGeometry.startPath(-302557, 7570663); lineGeometry.lineTo(-302959, 7570868); lineGeometry.lineTo(-303042, 7571220); lineGeometry.lineTo(-302700, 7571803); lineGeometry.lineTo(-304043, 7576654); lineGeometry.lineTo(-300544, 7585289); lineGeometry.lineTo(-294365, 7592435); lineGeometry.lineTo(-290122, 7594445); lineGeometry.lineTo(-285283, 7595488); GeometryEngine engine = new GeometryEngine(); Graphic lineGraphic = new Graphic(lineGeometry, lineSymbol); // here I get the maps corners to show that the polyline is way outside its boundaries so you either use points inside // or finds the spatial reference from the map you got the points from and use an engine as I do below to projet it to the correct one Polygon mapExtent = mMapView.getExtent(); System.out.println("mapViews extent " + mapExtent.toString() + " no of points " + mapExtent.getPointCount()); for(int i = 0; i < mapExtent.getPointCount(); i++){ System.out.println("point " + i +" " + mapExtent.getPoint(i).getX() + " x " + mapExtent.getPoint(i).getY() + " y "); } //PUT_YOUR POLYLINES SPATIAL REFERENCE WHERE IT IS SpatialReference.create(4326) NOW engine.project(lineGeometry, SpatialReference.create(4326), mapSpatialReference); mLocationLayer.addGraphic(lineGraphic); }
... View more
03-15-2015
06:03 AM
|
0
|
1
|
1544
|
POST
|
I just copied from a project I'm working on. The Route is a GPFeatureRecordSetLayer I get back from a service.
... View more
03-12-2015
06:39 AM
|
2
|
0
|
1544
|
POST
|
Im curious, If I should have tried the same I too would have assumed that removeAll() and then addLayer() would do the trick. So the question is... what do you use removeAll() to?
... View more
03-12-2015
05:53 AM
|
0
|
0
|
958
|
POST
|
I had the same problem (actually today like you ) and it occurs when the spatial references are not the same. This is how I solved it: 1. Make a field for the maps spatial reference private SpatialReference mapSpatialReference; 2. Save the maps spatial reference in onCreateView. You need to do it this way to be sure the map is fully initialized before you try to get the value. mapView = (MapView) view.findViewById(R.id.map); mapView.setOnStatusChangedListener(new OnStatusChangedListener() { private static final long serialVersionUID = 1L; public void onStatusChanged(Object source, STATUS status) { if (OnStatusChangedListener.STATUS.INITIALIZED == status && source == mapView) { mapSpatialReference = mapView.getSpatialReference(); } } }); 3. Check if the spatial references match and use a GeometryEngine to fix it if not. if(route != null) { locationDisplayManager.stop(); for (Graphic graphic : route.getGraphics()) { if (route.getSpatialReference().equals(mapSpatialReference)) { SimpleLineSymbol lineSymbol = new SimpleLineSymbol(R.color.orange, 5, SimpleLineSymbol.STYLE.SOLID); Polyline poly = (Polyline)graphic.getGeometry(); Graphic routeGraphic = new Graphic(poly, lineSymbol); myGraphicsLayer.addGraphic(routeGraphic); mapView.setExtent(routeGraphic.getGeometry(), 15); } else{ SimpleLineSymbol lineSymbol = new SimpleLineSymbol(R.color.orange, 5, SimpleLineSymbol.STYLE.SOLID); GeometryEngine engine = new GeometryEngine(); Polyline poly = (Polyline)engine.project(graphic.getGeometry(), route.getSpatialReference(), mapSpatialReference); Graphic routeGraphic = new Graphic(poly, lineSymbol); myGraphicsLayer.addGraphic(routeGraphic); mapView.setExtent(routeGraphic.getGeometry(), 15); } } Hope it helps. Now I only have to find out why my polyline is black instead of orange and why the setExtent doesn't work. The latter is probobly also related to the spatial reference.
... View more
03-12-2015
05:27 AM
|
2
|
2
|
1544
|
POST
|
You could also try if mapoptions like they explains here works: MapView | ArcGIS Android 10.2.5 API MapOptions streets = new MapOptions(MapType.STREETS); mapView.setMapOptions(streets);
... View more
03-06-2015
05:09 AM
|
1
|
1
|
958
|
POST
|
I dont know if it works (have not tried it myself) or if it helps you but they have an example that shows how to switch maps: https://developers.arcgis.com/android/sample-code/switch-maps/
... View more
03-06-2015
04:37 AM
|
0
|
3
|
958
|
POST
|
I gave up and investigated how to make the handler work instead and found a snippet that solved the issue I had. I put this in the onCreate: if (android.os.Build.VERSION.SDK_INT > 9) { StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); } and I start the job: Geoprocessor gpTask = new Geoprocessor(URL, creds); //Geoprocessor gpTask = new Geoprocessor(URL); if(handler != null){ handler.removeCallbacks(r); } handler = new Handler(); submitJobAndPolling(gpTask, parameters); and this is the method : void submitJobAndPolling(final Geoprocessor gpTask, List<GPParameter> params) { try { GPJobResource gpJobResource = gpTask.submitJob(params); GPJobResource.JobStatus jobstatus = gpJobResource.getJobStatus(); final String jobid = gpJobResource.getJobID(); status.setTextColor(getResources().getColor(R.color.text_dark_grey)); GPLong routeNo = (GPLong)params.get(0); status.setText("Fetching route " + routeNo.getValue()); if (jobstatus != GPJobResource.JobStatus.SUCCEEDED) { handler.postDelayed(r = new Runnable() { @Override public void run() { try { GPJobResource gpJobResource1 = gpTask.checkJobStatus(jobid); boolean jobcomplete = false; GPJobResource.JobStatus jobStatus = gpJobResource1.getJobStatus(); switch (jobStatus) { case CANCELLED: status.setTextColor(getResources().getColor(R.color.text_dark_grey)); status.setText("The job has been cancelled based on the client's request. "); jobcomplete = true; break; case CANCELLING: break; case DELETED: status.setTextColor(getResources().getColor(R.color.text_dark_grey)); status.setText("The job has been deleted. "); jobcomplete = true; break; case DELETING: break; case EXECUTING: break; case FAILED: status.setTextColor(getResources().getColor(R.color.text_dark_grey)); status.setText("The job execution has failed because of invalid parameters or other geoprocessing failures. "); jobcomplete = true; break; case NEW_JOB: break; case SUBMITTED: break; case SUCCEEDED: status.setTextColor(getResources().getColor(R.color.text_dark_grey)); status.setText("Added the route! "); jobcomplete = true; break; case TIMED_OUT: status.setTextColor(getResources().getColor(R.color.text_dark_grey)); status.setText("The job execution has timed out. "); jobcomplete = true; break; case WAITING: break; default: break; } if (jobcomplete) { if (jobStatus == GPJobResource.JobStatus.SUCCEEDED) { System.out.println("GP succeded"); }else { System.out.println("GP failed"); } } else { handler.postDelayed(this, 5000); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }, 4000); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } It works fine now.
... View more
03-05-2015
06:26 AM
|
1
|
0
|
262
|
POST
|
Hello, I am trying to use a Geoprocessor in an app to consume an aynchronous service. First I tried with Handler as in https://community.esri.com/thread/51073. But I could not figure out how to get it to work in a Fragment. So I decided to use AsyncTask instead. I get the right error message if I use wrong credentials and the job submits but then it stucks at jobstatus submitted. This is the input parameters: Parameter: VehicleID Data Type: GPLong Display Name: VehicleID Description: VID Direction: esriGPParameterDirectionInput Default Value: 1 Parameter Type: esriGPParameterTypeRequired Category: Parameter: CalculationID Data Type: GPLong Display Name CalculationID Description: CID Direction: esriGPParameterDirectionInput Default Value: 0 Parameter Type: esriGPParameterTypeRequired Category: This is how I start the job: public void sendJob(String username, String password, long id) throws Exception{ UserCredentials creds = new UserCredentials(); creds.setUserAccount(username, password); ArrayList<GPParameter> parameters = new ArrayList<GPParameter>(); GPLong idParam = new GPLong("VehicleID"); idParam.setValue(id); GPLong calcParam = new GPLong("CalculationID"); calcParam.setValue(0); parameters.add(idParam); parameters.add(calcParam); Geoprocessor gpTask = new Geoprocessor(URL, creds); if(downloadRouteTask != null){ if(downloadRouteTask.getStatus() == AsyncTask.Status.RUNNING){ downloadRouteTask.cancel(true); } } downloadRouteTask = new DownloadRouteTask(gpTask, status); downloadRouteTask.execute(parameters); //submitJobAndPolling(gpTask, parameters); } And this is the AsyncTask class: private class DownloadRouteTask extends AsyncTask<ArrayList<GPParameter>, String, GPJobParameter[]> { private Geoprocessor gpTask; private TextView textView; private String msg = ""; public DownloadRouteTask(Geoprocessor gpTask, TextView textView){ this.gpTask = gpTask; this.textView = textView; } @Override protected GPJobParameter[] doInBackground(ArrayList<GPParameter>... parameters) { GPJobParameter[] outParams = null; try { GPJobResource gpJobResource = gpTask.submitJob(parameters[0]); System.out.println("Polling thread is: " + Thread.currentThread().getName()); boolean done = false; while(!done) { if(isCancelled()){ break; } GPJobResource.JobStatus jobStatus = gpJobResource.getJobStatus(); switch (jobStatus) { case CANCELLED: msg = "The job has been cancelled based on the client's request. "; done = true; break; case CANCELLING: System.out.println("CANCELLING value on switch"); break; case DELETED: textView.setText("The job has been deleted. "); done = true; break; case DELETING: System.out.println("DELETING value on switch"); break; case EXECUTING: System.out.println("EXECUTING value on switch"); break; case FAILED: msg = "The job execution has failed because of invalid parameters or other geoprocessing failures. "; done = true; break; case NEW_JOB: System.out.println("NEW_JOB value on switch"); break; case SUBMITTED: System.out.println("SUBMITTED value on switch"); break; case SUCCEEDED: msg = "The job has completed successfully and the output results are available. "; outParams = gpJobResource.getOutputParameters(); done = true; break; case TIMED_OUT: msg = "The job execution has timed out. "; done = true; break; case WAITING: System.out.println("WAITING value on switch"); break; default: System.out.println("default value on switch"); } try { Thread.sleep(4000); } catch (InterruptedException e) { } } } catch(EsriSecurityException e){ if(e.getCode() == -10001){ msg = "There were no user with that name and password."; return null; } } catch (Exception e) { msg = e.getLocalizedMessage(); e.printStackTrace(); } return outParams; } @Override protected void onPostExecute(GPJobParameter[] result) { if(msg.length() > 0){ textView.setTextColor(getResources().getColor(R.color.text_dark_grey)); textView.setText(msg); } if(result != null) { if ( result.length > 0) { } else { textView.setTextColor(getResources().getColor(R.color.text_dark_grey)); textView.setText("There were no route with that id"); } } } // If the cancellation occurs, set the message informing so @Override protected void onCancelled() { textView.setTextColor(getResources().getColor(R.color.text_orange)); textView.setText("Job cancelled"); super.onCancelled(); } @Override public void onPreExecute(){ textView.setTextColor(getResources().getColor(R.color.text_dark_grey)); textView.setText("Fetching the route" ); } } I have made an app in Objective-C that does the same and it works so the service works.
... View more
03-04-2015
06:46 AM
|
0
|
1
|
2953
|
Title | Kudos | Posted |
---|---|---|
1 | 03-05-2015 06:26 AM | |
2 | 03-12-2015 06:39 AM | |
2 | 03-12-2015 05:27 AM | |
1 | 03-06-2015 05:09 AM |
Online Status |
Offline
|
Date Last Visited |
07-14-2023
04:46 PM
|