POST
|
Can I ask what you intend to do with the JSON? If your purpose it to cache the graphics to local storage, you will find that your performance hit will be significant as the number of graphics grows large. An exponentially faster solution for local caching is something like this. Initially the idea was to use Geometry.toJson() to persist Graphic objects between configuration changes and process termination (as is required by Core App Quality Guidelines - FN-S2). I'm using customized geocoding service, so extending Geometry to include all the extra data seemed like a good idea. I started testing serialization (Graphic.toJson()) but that didn't work... Another way to serialize Graphic into json is to use Jacksons' mixins, but you're correct, Serializable is better... Also it would be really nice to have Serializable Routes, since they also fall into category of things that should be retained between configuration changes and process termination. Making them (and also Graphic and other data) Parcelable would be even better... By the way, default Locator and RouteTask could really use cancel() or abort() method, phones usually have relatively awful connections and AsyncTasks.cancel() doesn't cancel anything.
... View more
03-05-2014
06:47 AM
|
0
|
0
|
571
|
POST
|
How about using SparseArray to handle references? Anyway, what about serialization (Graphic.toJson())? Is it a bug? Also MapGeometry vs. Geometry thing... I don't want to be pesky, but I'm really curious about those... 😄
... View more
03-04-2014
12:42 PM
|
0
|
0
|
571
|
POST
|
I took a look inside arcgis-android-api.jar, knisleyj's guess about what's taking place inside GraphicLayer's updateGraphic() method is mostly correct. Extending Graphic makes no sense, getGraphic() returns new and completely different Graphic object. Hopefully in future SDK updates Graphic will actually become immutable (final and without all that dead code). Although after seeing how addGraphic() method works I don't really understand why it should be. Also, why does graphic use Geometry instead of MapGeometry? Why is this SDK overly complicated...
... View more
03-03-2014
01:20 PM
|
0
|
0
|
571
|
POST
|
Thank you, that does clarify things a little bit. I agree that API is somewhat tedious, especially in android-specific areas (e.g. preservation of app state). By the way, here's the code I used to test Graphic.toJson(). I'm using 10.2 as well.
public void somethingIsWrong() {
Point point = new Point(577068, 6056541); // spat ref. wkid 3346
Symbol greenSymbol = new SimpleMarkerSymbol(Color.GREEN, 20, STYLE.DIAMOND);
Graphic graphic = new Graphic(point, greenSymbol);
Graphic customGraphic = new CustomGraphic(point, greenSymbol);
try {
Log.d(TAG, " graphic --> " + Graphic.toJson(graphic));
Log.d(TAG, " customGraphic --> " + Graphic.toJson(customGraphic));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public static class CustomGraphic extends Graphic {
private static final SpatialReference SR_WKID_3346 = SpatialReference.create(3346);
public CustomGraphic(Geometry geometry, Symbol symbol) {
super(geometry, symbol);
}
@Override
public SpatialReference getSpatialReference() {
return SR_WKID_3346;
}
}
03-01 04:36:03.716: D/DEBUG(21551): graphic --> {}
03-01 04:36:03.736: D/DEBUG(21551): customGraphic --> {"geometry":{"x":577068.0,"y":6056541.0,"spatialReference":{"wkid":2600,"latestWkid":3346}}}
... View more
02-28-2014
05:54 PM
|
0
|
0
|
571
|
POST
|
Documentation states that Graphic objects are immutable, but they appear to have mutators and none of their members are final (see Graphic.class file). Does framework use those setters to change graphic objects? Why do those setters exist? getSpacialReference() method is one big mystery. There is no way to pass spacial reference via any constructor or method, yet getter exists (it returns null). Where is spacial reference used by the framework and how do I pass it to the graphic? Is it safe to extend Graphic class and override the getter to return my own spacial reference? Is is safe to override any other method and return custom values? Graphic.toJson() returns empty json string if spacial reference is not set. Again - makes no sense, because there is no way to pass it. Overriding getSpacialReference() and returning a valid spacial reference fixes the problem. getUid() and getId() always return -1 (regardless of whether or not graphic is in the layer). What are those for?
... View more
02-27-2014
09:35 PM
|
0
|
8
|
1195
|
POST
|
Are there any updates on this issue? It is still present on 10.1.1... edit: also on 10.1.1 u1. Tested on samsung galaxy s4, samsung galaxy y, htc sense hd, samsung galaxy tab 3. The lag isn't very noticeable on galaxy y, sense hd and tab 3, but s4 becomes unusable. Also, methd profiling shows that gl thread keeps on calling nativeMapRenderToFile() untill activity is restarted on all of these devices.
... View more
10-03-2013
02:37 AM
|
0
|
0
|
575
|
POST
|
There some really simple drawing optimizations that can be implemented on MapView. Just sharing them. For example, take com.esri.arcgis.android.samples.helloworld. Set target android:targetSdkVersion="18" in manifest and target=android-18 in project.properties (actually, anything above android-10 will work). Now go to device Settings -> Developer options and enable "Show GPU overdraw" option. Start the sample. As you can see, map now has green overlay on it, meaning that there are 2 things overdrawing on the area the map is in. 1) Window background. It can be removed by calling getWindow().setBackgroundDrawable(null); somewhere in activity. This optmization might not be suitable for apps that don't have MapView covering their whole window. 2) MapView background drawable. Why does the MapView need background drawable? Who knows... but you can remove it by calling mMapView.setBackgroundDrawable(null); Hierarchy Viewer shows ~3ms decrease in drawing time.
... View more
09-26-2013
12:00 AM
|
0
|
1
|
704
|
POST
|
Is there a way to make MarkerSymbol rotate together with map? I did manage to rotate it using OnPinchListener, but I have to update update graphic manually and it's TERRIBLY SLOW.
mapView.setOnPinchListener(new OnPinchListener() {
...
public void postPointersUp(float arg0, float arg1, float arg2, float arg3, double arg4) {
markerSymbol.setAngle(-(float) mapView.getRotationAngle());
graphicsLayer.updateGraphic(graphicsLayer.getGraphicIDs()[0], markerSymbol);
}
public void postPointersMove(float arg0, float arg1, float arg2, float arg3, double arg4) {
markerSymbol.setAngle(-(float) mapView.getRotationAngle());
graphicsLayer.updateGraphic(graphicsLayer.getGraphicIDs()[0], markerSymbol);
}
);
So are there some other tricks to achieve something like this?
... View more
09-12-2013
10:59 PM
|
0
|
0
|
199
|
POST
|
MapView extends ViewGroup, so it must be an awful idea since it will leak the Context... at least thats what I think. http://android-developers.blogspot.com/2009/01/avoiding-memory-leaks.html
... View more
09-04-2013
09:40 PM
|
0
|
0
|
190
|
POST
|
I had the same problem. Couldn't find the way to get this runtime working on android emulator. Solution - get genymotion (just google it 🙂 ). The thing runs on Oracle VM and is actualy faster than a real device. Also, it nicely integrates with ADT and even works with Android Studio. Edit: oh, btw, you can also have and modify mockup GPS data (position, accuracy) with that thing on the go.
... View more
09-03-2013
05:56 AM
|
0
|
0
|
502
|
POST
|
bump It would be nice to know how to do this (preferably without writing your own animator...)
... View more
08-27-2013
02:08 AM
|
0
|
0
|
153
|
POST
|
android:configChanges="orientation|screenSize" Add this bit of code to your manifest -> activity. In android 4.x screenSize flag is a must, as it also triggers activity to be recreated. Edit: Also, it would be great if someone updated SDK samples to include this for android 4.x ...
... View more
08-20-2013
02:51 AM
|
0
|
0
|
271
|
POST
|
Hello 🙂 Can someone please explain why does MapView call requestLayout() on parent (or any other method that in turn leads to requestLayout() getting called) every time you move map with touch action? Pinching it doesn't have such effect. It makes no sense knowing what requestLayout() actually does. Is it a bug? Requesting layout leads to onMeasure() and onLayout() getting called, so this strange MapView behavior makes it impossible to use it with DrawerLayout and custom layouts (or anything that uses ViewDragHelper or offsets layout). In addition to that, deeper view hierarchies slow everything like crazy.
public class MapActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MapView map = new MapView(this);
map.addLayer(new OpenStreetMapLayer());
CustomLayout layout = new CustomLayout(this);
layout.addView(map);
setContentView(layout);
}
public static class CustomLayout extends FrameLayout {
public CustomLayout(Context context) {
super(context);
}
@Override
public void requestLayout() {
Log.d("wtf", "requestLayout()");
super.requestLayout();
}
}
}
... View more
08-20-2013
02:38 AM
|
0
|
0
|
1871
|
POST
|
Never mind, found it... setMinResolution did the trick 🙂
... View more
07-18-2013
05:37 AM
|
0
|
0
|
154
|
POST
|
Hello In my program I have a map that consists of 2 layers. 1st one is a basemap World_Light_Gray_Base (rest), the 2nd one is a LocalTiledLayer and I load it from androids external memory (it's a .tpk). The problem is that layers of the .tpk file appear only once you zoom beyond 1:150 (it's intentional, I use it for building interior) but there seems no way to zoom beyond that point, the maximum scale I am able to get is like 1:450 or something like that (it's the maximum of basemap, I assume). I tried using zoomToScale, but it still wont go beyond 1:450 (or whatever the maximum of that basemap is)... Is there a way to workaround this?
... View more
07-18-2013
05:18 AM
|
0
|
2
|
2924
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|