Creating a marker point
In this section, we will write code to add a marker point on the map to display
a picture of a cell phone. We can actually add a picture to the map by using the
picture marker element. So far we have managed to create a tool and get the x and
y coordinates of the mouse-click location. Then we learned how to create a point
geometry using those coordinates.
Follow these steps to create a point on the map:
1. Open our TelZaViBa project from the
C:\ArcGISByExample\telzaviba\Code if you have closed it.
2. We will now load the picture of the cell phone located in
C:\ArcGISByExample\telzaviba\Icons\Cell-phone.png and
add it to the map by creating a marker element and using the point
we created in the previous section as the geometry:
Protected Overrides Sub OnMouseUp(arg As ESRI.ArcGIS.Desktop.
AddIns.Tool.MouseEventArgs)
Dim pDocument As IMxDocument = My.ArcMap.Application.Document
Dim pPoint As IPoint = pDocument.ActiveView.ScreenDisplay.
DisplayTransformation.ToMapPoint(arg.X, arg.Y)
Dim pElement As IElement = New MarkerElement
pElement.Geometry = pPoint
Dim pMarkerElement As IMarkerElement = pElement
Dim pPictureMarkerSymbol As IPictureMarkerSymbol = New
PictureMarkerSymbol
pPictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictu
reType.esriIPicturePNG, "C:\ArcGISByExample\telzaviba\Icons\Cell-
phone.png")
pPictureMarkerSymbol.Size = 20
pMarkerElement.Symbol = pPictureMarkerSymbol
pDocument.ActiveView.GraphicsContainer.AddElement(pElement, 0)
pDocument.ActiveView.Refresh()
End Sub
In this section, we will write code to add a marker point on the map to display
a picture of a cell phone. We can actually add a picture to the map by using the
picture marker element. So far we have managed to create a tool and get the x and
y coordinates of the mouse-click location. Then we learned how to create a point
geometry using those coordinates.
Follow these steps to create a point on the map:
1. Open our TelZaViBa project from the
C:\ArcGISByExample\telzaviba\Code if you have closed it.
2. We will now load the picture of the cell phone located in
C:\ArcGISByExample\telzaviba\Icons\Cell-phone.png and
add it to the map by creating a marker element and using the point
we created in the previous section as the geometry:
Protected Overrides Sub OnMouseUp(arg As ESRI.ArcGIS.Desktop.
AddIns.Tool.MouseEventArgs)
Dim pDocument As IMxDocument = My.ArcMap.Application.Document
Dim pPoint As IPoint = pDocument.ActiveView.ScreenDisplay.
DisplayTransformation.ToMapPoint(arg.X, arg.Y)
Dim pElement As IElement = New MarkerElement
pElement.Geometry = pPoint
Dim pMarkerElement As IMarkerElement = pElement
Dim pPictureMarkerSymbol As IPictureMarkerSymbol = New
PictureMarkerSymbol
pPictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictu
reType.esriIPicturePNG, "C:\ArcGISByExample\telzaviba\Icons\Cell-
phone.png")
pPictureMarkerSymbol.Size = 20
pMarkerElement.Symbol = pPictureMarkerSymbol
pDocument.ActiveView.GraphicsContainer.AddElement(pElement, 0)
pDocument.ActiveView.Refresh()
End Sub
ليست هناك تعليقات:
إرسال تعليق