1

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

  • Where's your code where you actually USE the LocationService? Looking at the API docs, `.start()` just starts the service. Do you need to call `.setSymbol()` to tell the service how to draw your red dot? – Juffy Nov 12 '13 at 23:58
  • 1
    Since the type is esriPMS try defining the Symbol as PictureMarkerSymbol – atomaras Nov 13 '13 at 03:48

2 Answers2

1

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});

azmuhak
  • 964
  • 1
  • 11
  • 31
0

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.

Gary Sheppard
  • 4,764
  • 3
  • 25
  • 35
  • i did try your codes , but it doenst work . i still dont know what is the course of the problem –  Nov 15 '13 at 17:25
  • Create the GraphicsLayer and add it to the map before calling addGraphic, not after. – Gary Sheppard Nov 15 '13 at 17:38
  • 1
    @GaryS. How do I set width and height for PictureMarkerSymbol? –  Nov 04 '14 at 14:37
  • @20Cents: good question. I suspect you'll want to use the constructor that takes a Drawable instead of a URL string and scale the Drawable, as in http://stackoverflow.com/questions/4609456/android-set-drawable-size-programatically . – Gary Sheppard Nov 05 '14 at 15:23