Panning issue with arcgis maps 10.2.0 in android

2795
0
08-27-2014 05:02 AM
amitnalawade
New Contributor

Hi All ,

 

Greetings !

 

We have an android application built using arcgis api 10.2.0 .

 

We are able to load map and handle other events like zoom , pan. But there is particular issue while panning on the map. Even for slightest of the moment done on the map pan listener gets triggered and user has to wait for data refresh to take place which makes it frustrating.

 

Logic in place is something like this -

We have a pan listener setup and we are using below method to get from and to locations .Here we check the difference between 2 points and if user has panned considerable distance then based on map resolution we set the radial distance parameter. But this is not working properly because even for very small moment done somehow difference returned is large and therefore logic to refresh data gets executed. In this case ideally nothing should happen.

 

Code is as below :-

 

public void postPointerUp(float fromx, float fromy, float tox, float toy) {

 

  System.out.println("------------------OnPan() - postPointersUp------------------");

 

  Point locFrom = mapView.toMapPoint(fromx, fromy);

  Point pointFrom = (Point)GeometryEngine.project(locFrom, mapView.getSpatialReference(), egs4326);

 

  Point locTo = mapView.toMapPoint(tox, toy);

Point pointTo = (Point)GeometryEngine.project(locTo, mapView.getSpatialReference(), egs4326);

 

  double mapResolution = mapView.getResolution();

 

  double distanceOfPoints = GeometryEngine.distance(pointFrom, pointTo, egs4326);

  Point pointsDiff = (Point)GeometryEngine.difference(pointFrom, pointTo, egs4326);

 

  double latitudeDiff = pointsDiff.getY();

  double longitudeDiff = pointsDiff.getX();

 

 

//  getting map center point lat long so that data refresh happens at that position

  Point loc = mapView.getCenter();

  Point latLogPt = (Point)GeometryEngine.project(loc, mapView.getSpatialReference(), egs4326);

 

  double latitudeVal = latLogPt.getY();

  double longitudeVal = latLogPt.getX();

  LATITUDE = (float)latitudeVal;

  LONGITUDE = (float)longitudeVal;

 

  String radialDistance = "";

 

  float xdiff = tox - fromx;

  float ydiff = toy - fromy;

 

 

  if(totalxdiff >= 2.0 || totalydiff >= 2.0 ||

  totalxdiff <= -2.0 || totalydiff <= -2.0)

  {

  totalxdiff = xdiff;

  totalydiff = ydiff;

  }

  else

  {

// these is done to add up if user pans for some distance and then pans again

  totalxdiff = totalxdiff + xdiff;

  totalydiff = totalydiff + ydiff;

  }

 

  if(mapResolution >= 0 && mapResolution <= 15) {

  if(totalxdiff >= 2.0 || totalydiff >= 2.0

  || totalxdiff <= -2.0 || totalydiff <= -2.0 )

  radialDistance = "2.5";

  }

  else if(mapResolution > 15 && mapResolution <= 25) {

  if(totalxdiff >= 2.0 || totalydiff >= 2.0

  || totalxdiff <= -2.0 || totalydiff <= -2.0 )

  radialDistance = "5.0";

  }

  else if(mapResolution > 25 && mapResolution <= 50) {

  if(totalxdiff >= 2.0 || totalydiff >= 2.0

  || totalxdiff <= -2.0 || totalydiff <= -2.0 )

  radialDistance = "10.0";

  }

  else if(mapResolution > 50 && mapResolution <= 100) {

  if(totalxdiff >= 2.0 || totalydiff >= 2.0

  || totalxdiff <= -2.0 || totalydiff <= -2.0 )

  radialDistance = "25.0";

  }

  else if(mapResolution > 100 && mapResolution <= 200) {

  if(totalxdiff >= 2.0 || totalydiff >= 2.0

  || totalxdiff <= -2.0 || totalydiff <= -2.0 )

  radialDistance = "50.0";

  }

  else if(mapResolution > 200 && mapResolution <= 500) {

  if(totalxdiff >= 2.0 || totalydiff >= 2.0

  || totalxdiff <= -2.0 || totalydiff <= -2.0 )

  radialDistance = "75.0";

  }

  else if(mapResolution > 500 && mapResolution <= 1000) {

  if(totalxdiff >= 2.0 || totalydiff >= 2.0

  || totalxdiff <= -2.0 || totalydiff <= -2.0 )

  radialDistance = "100.0";

  }

  else if(mapResolution > 1000 && mapResolution <= 2500) {

  if(totalxdiff >= 0.4 || totalydiff >= 2.0

  || totalxdiff <= -2.0 || totalydiff <= -2.0 )

  radialDistance = "250.0";

  }

  else if(mapResolution > 2500 && mapResolution <= 3500) {

  if(totalxdiff >= 2.0 || totalydiff >= 2.0

  || totalxdiff <= -2.0 || totalydiff <= -2.0 )

  radialDistance = "350.0";

  }

  else if(mapResolution > 3500 && mapResolution <= 4500) {

  if(totalxdiff >= 2.0 || totalydiff >= 2.0

  || totalxdiff <= -2.0 || totalydiff <= -2.0 )

  radialDistance = "500.0";

  }

  else {

  radialDistance = "";

  }

 

  if(radialDistance == null || "".equals(radialDistance.trim())) {

// do nothing

  }

  else {

  SELECTED_DIST = radialDistance;

 

  // method call to refresh data

  }

  }

  catch(Exception e)

  {

  e.printStackTrace();

  }

  }

 

 

Please provide your inputs . Cannot find anything on this on internet

 

Thanks,

Amit.

0 Kudos
0 Replies