Display pin on location by Lat,Lon coordinates dynamically

3222
3
10-09-2012 09:51 PM
Vadimv
by
New Contributor
I want to display an pin image, to display it with my current gps coordinates its eady...just use start.
How can i set this pin to a specific coordinates of Lat,Lon...

I tried the next thing but its doest show nothing

AGSPictureMarkerSymbol *myMarkerSymbol = [AGSPictureMarkerSymbol pictureMarkerSymbolWithImageNamed:@"Pushpin.png"];
        myMarkerSymbol.color = [UIColor redColor];

[AGSPoint pointWithX:32.0636
                       y:34.7922
  spatialReference:[AGSSpatialReference spatialReferenceWithWKID:43276]];

  AGSGraphic* myGraphic =
 [AGSGraphic graphicWithGeometry:myMarkerPoint
                             symbol:myMarkerSymbol
                         attributes:nil
               infoTemplateDelegate:nil];
    
    [myGraphic addGraphic:myGraphic];
   [self.myGraphicsLayer dataChanged];

   [self.mapView addMapLayer:self.myGraphicsLayer withName:@"test];



Any ideas?
0 Kudos
3 Replies
NimeshJarecha
Esri Regular Contributor
1. You are creating point with spatial reference 43276. Is that correct? Or you meant 4326?

[AGSPoint pointWithX:32.0636 y:34.7922 spatialReference:[AGSSpatialReference spatialReferenceWithWKID:43276]];

2. Is you point's spatial reference is same as map's spatial reference (self.mapView.spatialReference)?

3. You should add graphic to graphics layer, not graphic to graphic.

//[myGraphic addGraphic:myGraphic];
[self.myGraphicsLayer addGraphic:myGraphic];

Hope this helps!

Regards,
Nimesh
0 Kudos
Vadimv
by
New Contributor
Thanks' Nimesh

[HTML]1. You are creating point with spatial reference 43276. Is that correct? Or you meant 4326?

[AGSPoint pointWithX:32.0636 y:34.7922 spatialReference:[AGSSpatialReference spatialReferenceWithWKID:43276]];
[/HTML]

Yeah i meant 4326(sorry for that),and tried with 4326. i just was trying some stuff and saved it like that.

[HTML]2. Is you point's spatial reference is same as map's spatial reference (self.mapView.spatialReference)?[/HTML]

Yes,Its the same..i'm using the same point to zoom the map,so the point is ok.

3. You should add graphic to graphics layer, not graphic to graphic.

[HTML]//[myGraphic addGraphic:myGraphic];
[self.myGraphicsLayer addGraphic:myGraphic];[/HTML]

I tried that too,its not changing. i'm using some layers to display stuff on the map.so the
myGraphicsLayer
is a layer that on the moment of calling this code is showen on the map, i tried also setting it to layer that not displayed and then calling it...

nothing works..
0 Kudos
NimeshJarecha
Esri Regular Contributor
Could you please try adding your graphics layer first to the map? and then try to add the graphic?

//add graphics layer first the map
[self.mapView addMapLayer:self.myGraphicsLayer withName:@"test];

//then add graphic to graphics layer
AGSPictureMarkerSymbol *myMarkerSymbol = [AGSPictureMarkerSymbol pictureMarkerSymbolWithImageNamed:@"Pushpin.png"];
        myMarkerSymbol.color = [UIColor redColor];
[AGSPoint pointWithX:32.0636 y:34.7922 spatialReference:[AGSSpatialReference spatialReferenceWithWKID:4326]];
AGSGraphic* myGraphic = [AGSGraphic graphicWithGeometry:myMarkerPoint symbol:myMarkerSymbol attributes:nil infoTemplateDelegate:nil];
[self.myGraphicsLayeraddGraphic:myGraphic];
[self.myGraphicsLayer dataChanged];


Regards,
Nimesh
0 Kudos