Select to view content in your preferred language

Add a point graphic to the center of the map

1185
7
05-11-2011 08:46 AM
JoshuaGumm
Deactivated User
I am using the Flex Viewer to zoom to a coordinate and would like to add a point graphic to the center of the map to show the location of the coordinate.  I imagine this must be fairly simple, but have not been able to find an example.  Any help is greatly appreciated.

Thanks
Tags (2)
0 Kudos
7 Replies
by Anonymous User
Not applicable
I am using the Flex Viewer to zoom to a coordinate and would like to add a point graphic to the center of the map to show the location of the coordinate.  I imagine this must be fairly simple, but have not been able to find an example.  Any help is greatly appreciated.

Thanks


This sample shows how to add graphics of different geometry types to a map:

http://help.arcgis.com/en/webapi/flex/samples/index.html?sample=AddingGraphics

In your case you want to add a MapPoint with a SimpleMarkerSymbol for example.
0 Kudos
JoshuaGumm
Deactivated User
This sample shows how to add graphics of different geometry types to a map:

http://help.arcgis.com/en/webapi/flex/samples/index.html?sample=AddingGraphics

In your case you want to add a MapPoint with a SimpleMarkerSymbol for example.


Thanks Michael, I saw that sample out there, but wasn't sure where the code would be placed within the Viewer's source code and how to specify the center of the map or use the URL parameters.  I appreciate the help.
0 Kudos
by Anonymous User
Not applicable
Thanks Michael, I saw that sample out there, but wasn't sure where the code would be placed within the Viewer's source code and how to specify the center of the map or use the URL parameters.  I appreciate the help.


Are you trying to use url parameters to have the viewer zoom to a location and draw a point?
0 Kudos
JoshuaGumm
Deactivated User
Are you trying to use url parameters to have the viewer zoom to a location and draw a point?


Yes, that is exactly what I am trying to do.  I'm looking at not using the Viewer and combining the URL parameters & graphics samples.

Thanks
0 Kudos
by Anonymous User
Not applicable
Yes, that is exactly what I am trying to do.  I'm looking at not using the Viewer and combining the URL parameters & graphics samples.

Thanks


In that case this sample shows how to read url parameters:

http://help.arcgis.com/en/webapi/flex/samples/index.html?sample=ReadURL

This example shows one way to combine them:

private function setMapLocation():void
   {
    var params:Object = getURLParameters();
    if (params["ll"])
    {
     var latlong:Array = String(params.ll).split(",");
     if (latlong.length == 2)
     {
      var centerPoint:MapPoint = WebMercatorUtil.geographicToWebMercator(new MapPoint(latlong[1], latlong[0])) as MapPoint;
      
      var myGraphicMarker:Graphic = new Graphic(centerPoint, new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_DIAMOND, 22, 0x009933));

      var graphicsLayer:GraphicsLayer = new GraphicsLayer();
      graphicsLayer.name = "locationGraphics";
      graphicsLayer.add(myGraphicMarker);
       
      map.addLayer(graphicsLayer);
      
      map.centerAt(centerPoint);
     }
    }
    if (params["scale"])
    {
     map.scale = params.scale;
    }
   }
0 Kudos
JoshuaGumm
Deactivated User
Thanks for your reply Michael, this was the same track I was on, but I am getting error "1120: Access of undefined property map" on map.addLayer, map.centerAt & map.scale.  I see in the sample that the map is defined when creating the new MapPoint using the URL parameters, but wondering how this should be defined in the above example? 

Thanks,
Josh
0 Kudos
JoshuaGumm
Deactivated User
Thanks for the help Michael.  Got this working and just have a few other things I want to add and tweak.

Thanks again,
Josh
0 Kudos