<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: AGSPoint Issue - PointWithX Not Accepting Coordinates in ArcGIS Runtime SDK for iOS Questions</title>
    <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/agspoint-issue-pointwithx-not-accepting/m-p/336247#M2921</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi there, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Seems that your base map or map's spatial reference is not WGS1984 &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try AGSPoint *myPoint = [AGSPoint pointWithX:*** y:*** spatialReference:[AGSSpatialReference wgs84SpatialReference]];&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can also check this link about the AGSPoint setting:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="https://github.com/Esri/quickstart-map-ios/blob/master/Lib/EsriQuickStartLib/AGS%20Categories/General/AGSPoint%2BEQSGeneralUtilities.m"&gt;https://github.com/Esri/quickstart-map-ios/blob/master/Lib/EsriQuickStartLib/AGS%20Categories/General/AGSPoint%2BEQSGeneralUtilities.m&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 08 Apr 2014 15:45:35 GMT</pubDate>
    <dc:creator>YueWu1</dc:creator>
    <dc:date>2014-04-08T15:45:35Z</dc:date>
    <item>
      <title>AGSPoint Issue - PointWithX Not Accepting Coordinates</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/agspoint-issue-pointwithx-not-accepting/m-p/336245#M2919</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm sure this is something simple I'm missing, but I'm just not seeing it. I'm trying to add a single point abject to a graphics layer and no matter what I do, the point is always showing up just off the western coast of Africa (basically, center of the world map). This is under 10.2 and Xcode 5.1.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My code to do this is as follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;- (void) plotPoints { &amp;nbsp;&amp;nbsp;&amp;nbsp; //--- Add a sample point. ---// &amp;nbsp;&amp;nbsp;&amp;nbsp; //--- First, set up a symbol for the point. ---// &amp;nbsp;&amp;nbsp;&amp;nbsp; AGSSimpleMarkerSymbol *myMarkerSymbol = [AGSSimpleMarkerSymbol simpleMarkerSymbol]; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; myMarkerSymbol.color = [UIColor blueColor]; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //--- Now, create a point for the graphic to be drawn. ---// &amp;nbsp;&amp;nbsp;&amp;nbsp; AGSPoint *myPoint = [AGSPoint pointWithX:-96.6477 y:33.0477 spatialReference:self.mapView.spatialReference]; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //--- Create a graphic using the marker and point. ---// &amp;nbsp;&amp;nbsp;&amp;nbsp; AGSGraphic *myGraphic = [AGSGraphic graphicWithGeometry:myPoint symbol:myMarkerSymbol attributes:nil]; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //--- Add the graphic to the graphic layer. ---// &amp;nbsp;&amp;nbsp;&amp;nbsp; [self.graphicsLayer addGraphic:myGraphic];&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is being called from my viewDidLoad after opening a base map (ArcGIS Online) and adding the graphic layer. The point displays fine with the exception of the location never changing. Is there somehow a difference in the spatialReference that is causing the coordinates to be thrown out?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Edit: After further playing around, it does appear that this is an issue with the coordinate system between the map and the coordinates I'm providing. How do I go about converting from X/Y to whatever units the map is using?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Edit 2: I found a prior post that had the following algorithm in it that has my point in the proper area now.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //convert longitude and latitude to map point X Y &amp;nbsp;&amp;nbsp;&amp;nbsp; double mercatorX = longitude * 0.017453292519943295 * 6378137.0; &amp;nbsp;&amp;nbsp;&amp;nbsp; double a = latitude * 0.017453292519943295; &amp;nbsp;&amp;nbsp;&amp;nbsp; double mercatorY = 3189068.5 * log((1.0 + sin(a))/(1.0 - sin(a)));&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This will get me where I need to be, but it seems like there should be a built in method to do this. I'd prefer to use something a bit more standard if possible.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Apr 2014 14:13:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/agspoint-issue-pointwithx-not-accepting/m-p/336245#M2919</guid>
      <dc:creator>DarrenSulfridge</dc:creator>
      <dc:date>2014-04-07T14:13:34Z</dc:date>
    </item>
    <item>
      <title>Re: AGSPoint Issue - PointWithX Not Accepting Coordinates</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/agspoint-issue-pointwithx-not-accepting/m-p/336246#M2920</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can use AGSGeometryGeographicToWebMercator() function to cover WGS 1984 coordinate to web mercator. Also, you can use AGSGeometryEngine's &lt;/SPAN&gt;&lt;A href="https://developers.arcgis.com/ios/api-reference/interface_a_g_s_geometry_engine.html#adf9adc2b5ec8aea58a166a9b97192f8d"&gt;projectGeometry:toSpatialReference:&lt;/A&gt;&lt;SPAN&gt; method to project geometries in different spatial reference.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Nimesh&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Apr 2014 14:56:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/agspoint-issue-pointwithx-not-accepting/m-p/336246#M2920</guid>
      <dc:creator>NimeshJarecha</dc:creator>
      <dc:date>2014-04-08T14:56:50Z</dc:date>
    </item>
    <item>
      <title>Re: AGSPoint Issue - PointWithX Not Accepting Coordinates</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/agspoint-issue-pointwithx-not-accepting/m-p/336247#M2921</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi there, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Seems that your base map or map's spatial reference is not WGS1984 &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try AGSPoint *myPoint = [AGSPoint pointWithX:*** y:*** spatialReference:[AGSSpatialReference wgs84SpatialReference]];&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can also check this link about the AGSPoint setting:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="https://github.com/Esri/quickstart-map-ios/blob/master/Lib/EsriQuickStartLib/AGS%20Categories/General/AGSPoint%2BEQSGeneralUtilities.m"&gt;https://github.com/Esri/quickstart-map-ios/blob/master/Lib/EsriQuickStartLib/AGS%20Categories/General/AGSPoint%2BEQSGeneralUtilities.m&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Apr 2014 15:45:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/agspoint-issue-pointwithx-not-accepting/m-p/336247#M2921</guid>
      <dc:creator>YueWu1</dc:creator>
      <dc:date>2014-04-08T15:45:35Z</dc:date>
    </item>
    <item>
      <title>Re: AGSPoint Issue - PointWithX Not Accepting Coordinates</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/agspoint-issue-pointwithx-not-accepting/m-p/336248#M2922</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;You can use AGSGeometryGeographicToWebMercator() function to cover WGS 1984 coordinate to web mercator. Also, you can use AGSGeometryEngine's &lt;A href="https://developers.arcgis.com/ios/api-reference/interface_a_g_s_geometry_engine.html#adf9adc2b5ec8aea58a166a9b97192f8d" rel="nofollow noopener noreferrer" target="_blank"&gt;projectGeometry:toSpatialReference:&lt;/A&gt; method to project geometries in different spatial reference.&lt;BR /&gt;&lt;BR /&gt;Hope this helps!&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Nimesh&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm finally getting back to working on this and unfortunately, I'm not making any headway with your suggestion. Is there an example of using this on an AGS point somewhere?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My current code is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;- (void) plotPoints
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; //--- Add a sample point. ---//
&amp;nbsp;&amp;nbsp;&amp;nbsp; //--- First, set up a symbol for the point. ---//
&amp;nbsp;&amp;nbsp;&amp;nbsp; AGSSimpleMarkerSymbol *myMarkerSymbol = [AGSSimpleMarkerSymbol simpleMarkerSymbol];
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; myMarkerSymbol.color = [UIColor greenColor];
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //--- Sample lat/long to test with. ---//
&amp;nbsp;&amp;nbsp;&amp;nbsp; float longitude = -96.6477;
&amp;nbsp;&amp;nbsp;&amp;nbsp; float latitude = 33.0477;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //--- Convert longitude and latitude to map point X Y ---//
&amp;nbsp;&amp;nbsp;&amp;nbsp; double mercatorX = longitude * 0.017453292519943295 * 6378137.0;
&amp;nbsp;&amp;nbsp;&amp;nbsp; double a = latitude * 0.017453292519943295;
&amp;nbsp;&amp;nbsp;&amp;nbsp; double mercatorY = 3189068.5 * log((1.0 + sin(a))/(1.0 - sin(a)));
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //--- Now, create a point for the graphic to be drawn. ---//
&amp;nbsp;&amp;nbsp;&amp;nbsp; AGSPoint *myPoint = [AGSPoint pointWithX:mercatorX y:mercatorY spatialReference:self.mapView.spatialReference];
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //--- Create a graphic using the marker and point. ---//
&amp;nbsp;&amp;nbsp;&amp;nbsp; AGSGraphic *myGraphic = [AGSGraphic graphicWithGeometry:myPoint symbol:myMarkerSymbol attributes:nil];
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //--- Add the graphic to the graphic layer. ---//
&amp;nbsp;&amp;nbsp;&amp;nbsp; [self.graphicsLayer addGraphic:myGraphic];
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //--- Force a better initial view for testing. ---//
&amp;nbsp;&amp;nbsp;&amp;nbsp; AGSMutableEnvelope *extent = [self.graphicsLayer.fullEnvelope mutableCopy];
&amp;nbsp;&amp;nbsp;&amp;nbsp; [extent expandByFactor:1.5];
&amp;nbsp;&amp;nbsp;&amp;nbsp; [self.mapView zoomToEnvelope:extent animated:YES];
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
}&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;No matter what I set the spatial reference to in the call to pointwithx, I have to use the manual conversion and not the direct lat/long values. Shouldn't this change where the point is drawn, even if it is still incorrectly placed? I guess I really don't understand what is going on at all in the ESRI side of the code.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:56:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/agspoint-issue-pointwithx-not-accepting/m-p/336248#M2922</guid>
      <dc:creator>DarrenSulfridge</dc:creator>
      <dc:date>2021-12-11T15:56:24Z</dc:date>
    </item>
    <item>
      <title>Re: AGSPoint Issue - PointWithX Not Accepting Coordinates</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/agspoint-issue-pointwithx-not-accepting/m-p/336249#M2923</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Darren,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Let me try to explain. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You are trying to add a graphic on a map. You are assigning the graphic a point geometry whose x &amp;amp; y coordinates are in lat/long format, basically decimal degrees. This implies that your point geometry is WGS84 spatial reference.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The map you are using is probably in WebMercator spatial reference. The x&amp;amp; y coordinates on this map are expressed in meter values. Therefore, the lat/long values you are using for your graphic will not show up in the right location on the map. They will, as you observed, be somewhere near the center. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To get this all to work, you need to perform one additional step of projecting your point geometry which uses WGS84 spatial reference into Web Mercator. You can then use this projected result in your graphic and place it correctly on the map. The Runtime SDK does not automatically project geometries for you.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; float longitude = -96.6477; &amp;nbsp;&amp;nbsp;&amp;nbsp; float latitude = 33.0477; &amp;nbsp; AGSPoint *wgs84Point = [AGSPoint pointWithX:longitude y:latitude spatialReference:[AGSSpatialReference wgs84SpatialReference]];&amp;nbsp; //This example shows using GeometryEngine to project, but&amp;nbsp; you can also AGSGeometryGeographicToWebMercator() function //See https://developers.arcgis.com/ios/api-reference/_a_g_s_geometry_8h.html#ac501960bbf7012239968ba9107935430&amp;nbsp;&amp;nbsp; AGSGeometryEngine* ge = [AGSGeometryEngine defaultGeometryEngine]; AGSPoint* webmercatorPoint = [ge projectGeometry:wgs84Point toSpatialReference:[AGSSpatialReference webMercatorSpatialReference&amp;nbsp;&amp;nbsp;&amp;nbsp; ]];&amp;nbsp;&amp;nbsp; AGSGraphic *myGraphic = [AGSGraphic graphicWithGeometry:webmercatorPoint symbol:myMarkerSymbol attributes:nil]; ...&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Apr 2014 23:33:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/agspoint-issue-pointwithx-not-accepting/m-p/336249#M2923</guid>
      <dc:creator>DiveshGoyal</dc:creator>
      <dc:date>2014-04-24T23:33:10Z</dc:date>
    </item>
    <item>
      <title>Re: AGSPoint Issue - PointWithX Not Accepting Coordinates</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/agspoint-issue-pointwithx-not-accepting/m-p/336250#M2924</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I just got a chance to try this and it does appear to be working! I'm getting a warning that the call to projectgeometry is returning a type AGSGeometry rather than an AGSPoint, but it is still putting the point in the proper location.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One bit of oddness. If I try to pull the current spatial reference from the map view instead of hardcoding it to web mercator, it will not draw my point. It seems like it's putting the point in the proper location as the extent is identical to what I would get with the hard coded spatial reference, but it's not showing the point. It's not a high deal, I just don't quite understand why it's doing that. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I do appreciate the assistance!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Darren&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 May 2014 19:03:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/agspoint-issue-pointwithx-not-accepting/m-p/336250#M2924</guid>
      <dc:creator>DarrenSulfridge</dc:creator>
      <dc:date>2014-05-06T19:03:08Z</dc:date>
    </item>
  </channel>
</rss>

