Arcgis Map : PictureMarkerSymbol - java

Hie everybody, i am trying to make a PictureSymbolMarker in my arcgis map..
However i am facing some problems in it. i went to esri website [ http://blogs.esri.com/esri/arcgis/2012/02/03/esri-picture-marker-symbol-generator-for-javascript-developers/ ] to get a pin url .
When i tried to implement it in my codes,
i received error .
This is how i put it together
From
`//Marker
SimpleMarkerSymbol resultSymbol = new SimpleMarkerSymbol(Color.RED,
20, SimpleMarkerSymbol.STYLE.CIRCLE);`
To
`SimpleMarkerSymbol resultSymbol = new SimpleMarkerSymbol
({"angle":0,"xoffset":0,"yoffset":12,"type":"esriPMS",
"url":"http://static.arcgis.com/images/Symbols/Basic/RedStickpin.png",
"contentType":"image/png","width":24,"height":24});`
But after implementing that codes, i received errors. .. Anybody have face the same problem and are enable to troubleshoot it?
Thanks in Advance

your issue is that you are using JSON for a PictureMarkerSymbol and initializing a SimpleMarkerSymbol which will never work. Try to do like this.
var resultSymbol = new esri.symbol.PictureMarkerSymbol
({"angle":0,"xoffset":0,"yoffset":12,"type":"esriPMS",
"url":"http://static.arcgis.com/images/Symbols/Basic/RedStickpin.png",
"contentType":"image/png","width":24,"height":24});

You're using JavaScript object notation (JSON) syntax in your Java code for Android. It won't work.
#azmuhak is on the right track though. You need to create a PictureMarkerSymbol instead of a SimpleMarkerSymbol. But you need to do it the Android way, not the JavaScript way.
Here's some sample code for creating a PictureMarkerSymbol, creating a GraphicsLayer, adding the GraphicsLayer to the map, and adding a new Graphic to the GraphicsLayer (run this code after the map is loaded, maybe using MapView.setOnStatusChangedListener):
PictureMarkerSymbol pms = new PictureMarkerSymbol(
"http://static.arcgis.com/images/Symbols/Basic/RedStickpin.png");
pms.setAngle(0f);
pms.setOffsetX(0f);
pms.setOffsetY(12f);
GraphicsLayer graphicsLayer = new GraphicsLayer();
mMapView.addLayer(graphicsLayer);
graphicsLayer.addGraphic(new Graphic(new Point(12, 34), pms));
Side note: it is possible in Android to parse a JSON string to make a PictureMarkerSymbol. But in this case, my sample code is easier and less error-prone.

Related

Gson parsing a Json file

i am trying to parse the following json file in java with gson:
So , I am trying to retrieve only the issues into a list of Issue. I have the following class to store the issue information:
But i got an error.. I am trying to get with the following but I think that i am so lost with this ( i am learning about this ) and i dont understand the error
any idea of how to do this? thank you so much!
obj.get("issues")
will actually return a List Object, and not an Issue Object. You need to change the second parameter accordingly.

How to edit a Json key from an URL ( Android Studio )

So here's the deal , I already generated this Json URL :
https://api.myjson.com/bins/w7wuz
And I did some code om my app in order to read it. So far so good.
But I'm struggling a bit , trying to edit a key on my Json URL , to see if my app would update the value as well .
I hope I was clear with what I pretend. Thanks guys .
Add a new parameter to your URL then possible otherwise not possible in my view.
Like :
https://api.myjson.com/bins/w7wuz?id=1
https://api.myjson.com/bins/w7wuz?id=2&name=kaushal

OnTap API: How can I get volume attributes?

I am using OnTap API and I am talking to 7-Mode NetApp filer. I am able to get a list of volumes, but I cannot figure out how to get volume attributes. I tried to use VolumeGetIterResponse class, here is a code snippet:
VolumeGetIterRequest volumeGetIter = new VolumeGetIterRequest();
volumeGetIter.setMaxRecords(100);
List<VolumeAttributes> volAttributes = volumeGetIterResponse.getAttributesList();
for (VolumeAttributes vas : volAttributes) {
VolumeExportAttributes vs = vas.getVolumeExportAttributes();
}
When running this code, I get an error:
Unable to find API: volume-get-iter
Please help me figure out where I am going wrong. Your help is greatly appreciated.
From your error, it appears you're using the "volume-get-iter" API. This is a Cluster-Mode API. Since you're talking to a 7-mode, you will need "volume-list-info".

LibGDX: Cannot load a json file from assets folder

I have a json file with data for all the tiles in my game that I store in the assets folder. I try to access and parse it using TileList dataList = json.fromJson(TileList.class, Gdx.file.internal("map-elements/tiles/tiles.json")). This works fine for the desktop version but on the html version, after converting with gwt, I get these errors:
GwtApplication: exception: Error reading file: map-elements/tiles/tiles.json
Error reading file: map-elements/tiles/tiles.json
Couldn't find Type for class 'net.vediogames.archipelo.world.tiles.TileList'
TileList is a simple object that contains an array of TileData which can then be converted into Tile objects. I did it this way to make the json parsing easy.
The solution to the json error is simple. Instead of passing the FileHandle into the json parser, pass the string from the file like this:
TileList dataList = json.fromJson(TileList.class, Gdx.file.internal("map-elements/tiles/tiles.json").readString());
In the end, all I needed to do to solve that issue is add .readString(). As for the Couldn't find Type for class 'net.vediogames.archipelo.world.tiles.TileList' error, I also found a solution but it is more complicated.
JavaScript handles class references differently than Java. So I was not able to use TileList.class without first registering it so LibGDX can generate a Reflection. What I needed to do was add this line into my *.gwt.xml files:
<extend-configuration-property name="gdx.reflect.include" value="net.vediogames.archipelo.world.tiles.TileList" />
If you want a full tutorial about how reflection works and how to include packages or exclude, please view the official LibGDX tutorial here.
Your solution was not working for me, I still got the same error. After some hours of testing I got it to work, using your suggestions and by using the ClassReflection instead of referencing the class itself.
Your example:
TileList dataList = json.fromJson(TileList.class, Gdx.file.internal("map-elements/tiles/tiles.json").readString());
looks in my working code like:
TileList dataList = (TileList) json.fromJson(ClassReflection.forName(TileList.class.getName()), Gdx.file.internal("map-elements/tiles/tiles.json").readString());
This is quite a pain in the a.. but I'm glad it is finally working now.

GWT/google visualization wrapper 2 y-axis

I am using GWT 2.5 and the JAVA Google Visualization wrapper 1.1.2.
I try to create a line Chart with 2 y-axis (it works fine with one). I know it is possible in pure javascript but I don't find any answer for java.
I read GWT Linechart options and try this :
AxisOptions axes[] = new AxisOptions[2];
axes[0] = firstAxis;
axes[1] = secondAxis;
options.set("vAxes", axes); //not working
AxisOptions are correctly created and using code like the one below works fine :
options.set("vAxis", firstAxis);
Someone knows how to do a 2 Y-axis line chart ?
Thanks!
Why don't you use the second version of the SO thread you referenced?
If you must pass an array to the AxisOption you have to use a JsArray instead.
Something like this:
JsArray<AxisOptions> axes= AxisOptions.createArray().cast();
axes.push(firstAxis);
axes.push(secondAxis);
options.set("vAxes",axes);

Categories

Resources