POST
|
I'm writing a WPF application, in C#, using ArcObjects. I have an ESRI.ArcGIS.Controls.AxMapControl on my form, and I'm trying to draw some graphics elements on top of it. The map I'm developing with is a customer-provided mdf of the state of Georgia. Over the top of this, I need to display some markers and some text. It's taken a while, but I've figured out how to do this, except that the image and the text scales with the map. If it looks good at one zoom, it's way too big or way too small at others. What I'd like is for the marker and text to be placed at a lat/long, so that it moves as the map is panned, but at a fix size that doesn't change as the map is zoomed in and out. I'd thought that setting ScaleText = false would solve this for the text, but it doesn't seem to, and I'm not seeing any method for doing this with markers. My current attempt: public void addMarker(IMap map, double x, double y, string text, string imagePath)
{
var point = new PointClass() {X = x, Y = y};
var pictureMarkerSymbol = new PictureMarkerSymbolClass
{
Size = 15,
BitmapTransparencyColor = new RgbColorClass
{
Red = 0,
Green = 0,
Blue = 0
}
};
pictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, imagePath);
var markerElement = new MarkerElementClass
{
Symbol = pictureMarkerSymbol,
Geometry = point
};
var textElement = new TextElementClass
{
Text = text,
ScaleText = false,
Symbol = new TextSymbolClass
{
XOffset = 40,
Size = 10
}
};
((IElement) textElement).Geometry = point;
(map as IGraphicsContainer)?.AddElement(((IElement)textElement), -1);
(map as IGraphicsContainer)?.AddElement(((IElement)markerElement), 0);
(map as IActiveView)?.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
} I recognize that the above is stylistically very different from the usual ESRI examples. I find the typical ESRI example almost unreadable. If you strip the more recent C# syntactic sugar from the above, you get the following, which should (and does, in my testing), behave identically: public void addMarker(IMap map, double x, double y, string text, string imagePath)
{
IPoint point = new PointClass();
point.X = x;
point.Y = y;
IRgbColor rgbColorClass = new RgbColorClass();
rgbColorClass.Red = 0;
rgbColorClass.Green = 0;
rgbColorClass.Blue = 0;
IPictureMarkerSymbol pictureMarkerSymbol = new PictureMarkerSymbolClass();
pictureMarkerSymbol.Size = 15;
pictureMarkerSymbol.BitmapTransparencyColor = rgbColorClass;
pictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, imagePath);
IMarkerElement markerElement = new MarkerElementClass();
markerElement.Symbol = pictureMarkerSymbol;
IElement eMarkerElement = (IElement) markerElement;
eMarkerElement.Geometry = point;
var textSymbol = new TextSymbolClass();
textSymbol.XOffset = 40;
textSymbol.Size = 10;
var textElement = new TextElementClass();
textElement.Text = text;
textElement.ScaleText = false;
textElement.Symbol = textSymbol;
IElement eTextElement = (IElement) textElement;
eTextElement.Geometry = point;
IGraphicsContainer gcMap = (IGraphicsContainer) map;
gcMap.AddElement(eTextElement, -1);
gcMap.AddElement(eMarkerElement, 0);
IActiveView avMap = (IActiveView) map;
avMap.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
} Anyone have any ideas how I can make this marker and text draw at a fixed size independent of zoom?
... View more
07-08-2016
01:52 PM
|
0
|
0
|
2558
|
POST
|
I'm writing a WPF applicating, in C#, using ArcObjects. I have an ESRI.ArcGIS.Controls.AxMapControl on my form, and I'm trying to draw some graphics elements on top of it. The map I'm developing with is a customer-provided mdf of the state of Georgia. I'm trying an example I found here: http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//0001000001rv000000 public void AddTextElement(IMap map, double x, double y)
{
IGraphicsContainer graphicsContainer = map as IGraphicsContainer;
IElement element = new TextElementClass();
ITextElement textElement = element as ITextElement;
//Create a point as the shape of the element.
IPoint point = new PointClass();
point.X = x;
point.Y = y;
element.Geometry = point;
textElement.Text = "Hello World";
graphicsContainer.AddElement(element, 0);
//Flag the new text to invalidate.
IActiveView activeView = map as IActiveView;
activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
} It took while to figure out how to project the lat/long of Atlanta to the coordinate system of the map, but I'm pretty sure that I've got it right. The x/y values I'm passing into AddTextElement() are clearly within the Atlanta area, according to the Location data I see when I use the Identify tool on the map. But I'm not seeing the text. Everything seems to be working correctly, but I'm not seeing the text. I can see a number of possibilities: - The layer I'm adding the TextElement to isn't visible, or doesn't exist. - I need to apply a spatial reference system to the point I'm setting as the TextElement's geometry - The text is drawing fine, but there's something wrong with the font - it's invisibly small, or in a transparent color, etc. Haven't a clue, which. I was hoping there was something obvious I was missing. --- More info --- I've been looking at a different tutorial: http://resources.esri.com/help/9.3/arcgisengine/dotnet/7bd52ed1-18ae-4aa7-8cde-e9eaed9537fe.htm This includes a custom control that writes the current date to the map, at the point that you click it with the mouse: public override void OnMouseDown(int Button, int Shift, int X, int Y)
{
//Get the active view.
IActiveView activeView = m_hookHelper.ActiveView;
//Create a new text element.
ITextElement textElement = new TextElementClass();
//Create a text symbol.
ITextSymbol textSymbol = new TextSymbolClass();
textSymbol.Size = 25;
//Set the text element properties.
textElement.Symbol = textSymbol;
textElement.Text = DateTime.Now.ToShortDateString();
//Query interface (QI) for IElement.
IElement element = (IElement)textElement;
//Create a point.
IPoint point = new PointClass();
point = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
//Set the element's geometry.
element.Geometry = point;
//Add the element to the graphics container.
activeView.GraphicsContainer.AddElement(element, 0);
//Refresh the graphics.
activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
} This actually succeeds in writing text to the map, but it confuses me. When I click on the map, and enter into OnMouseDown, X is 183 and Y is 266 - clearly pixel coordinates. (That they are of type int would suggest that.) The but after point is created, by calling DisplayTransformation.ToMapPoint(), it has X and Y of 2.5048801369863014 and 8.3338184931506856. That's not lat/long and it's not map coordinates. But when I use that as my TextElement's geometry and add it to the GraphicsContainer, it does display the text on the map. Are these some sort of screen coordinates? If so, how do I convert lat/long to screen coordinates? And if they are screen coordinates, why doesn't my first example work, when I use the screen coordinate values to locate the text? ---- So, I added the custom control from the second example to the map on the first. Noticed two things: 1. The coordinates of the point returned by activeView.ScreenDisplay.DisplayTransformation.ToMapPoint() appear to be map coordinates. 2. I still don't see the text appear on the map. This suggests to me that the problem isn't coordinates, or fonts, or colors, but that there isn't an active graphics layer on the map. How do I add one? ---- At this point, I have to say "never mind". Turns out my problem is scaling. My text is being drawn on the map, only at a scale that is invisible unless I zoom in considerably. My "Hello, world" text is drawn at a fixed size, on the map, and scales with the map. With a default size of only a hundred feet or so, which isn't visible when zoomed to see the entire state. If I set the size to 25, it's a bit larger, but still essentially invisible. I need to set it to 25000 before its legible on the map. What I need, now, is to figure out how to draw markers and text on the map at a size that is independent of the zoom level. And that's another question, entirely.
... View more
07-07-2016
11:36 AM
|
1
|
0
|
2754
|
POST
|
The only reason we need map packages is so that we can display them in our app, using the .NET SDK controls. The MXDs are created by major utility companies, contain layers for all of their facilities, are changed almost daily, and are installed on the windows laptops by the customer, without our interaction. We can't clean up the MXDs, and the decision has been made that we're not going to ask the customers to, either. Essentially, we're abandoning any effort to use the ArcGIS Runtime for .NET SDK, and are going back to ArcObjects, which supports the MXD files without modification.
... View more
07-07-2016
11:27 AM
|
0
|
0
|
352
|
POST
|
I'm building a windows application that uses ESRI.ArcGIS.Controls.AxMapControl. I've figured out how to create the map, and to populate it from a .mxd. Now I need to programmatically draw some markers and geometries on the map. I have a set of objects - in memory, not in some external map source - each of which contains a pair of coordinates in latitude/longitude, an ID, and a bit of data. Basically, these represent jobs that the user needs to do. I need to display a marker, at each of the lat/longs, that displays the ID, and has a popup form that displays the data. I need to be able to open or close the popup form, from my program. I need to be able to change the data displayed in the form, I need to be informed, when the user clicks on a marker, so that I can do some stuff in my program based on which job he clicked. I'm not new to mapping, I've done this sort of thing with OpenLayers, and with Leaflet, and with Telerik's WPF control. But ESRI provides a huge selection of capabilities, but nothing I've seen yet jumps out as the obvious way to approach this sort of problem. Any ideas?
... View more
06-29-2016
11:21 AM
|
0
|
0
|
1172
|
POST
|
We have an old VB6 application that uses ESRI's VB map control to display map data that our customers' install locally on the laptops that are running the app. I'm working on a XAML/WPF replacement using ArcGIS runtime for .NET, and I'm not having much luck getting started. The customers use maps with varying degrees of sophistication, but some make extensive use of ArcMap capabilities, and configure varying numbers of controls within the map - feature queries, searches, distance measurement, etc. It's not clear to me to what degree ArcGIS runtime for .NET supports these. To date, I've not even been able to load a map. Or, rather, I've not been able to create a map package. The customer who needs this first has sent me an .mxd file, with accompanying .gsd's. When I try to create a map package with runtime support, in ArcMap 10.4, I get errors: 00174 Label expression uses VBScript, this is not support in the ArcGIS Runtime 24067 Annotation expression from annotation class "Default" uses VBScript, this is not supported in the ArcGIS Runtime 10001 Layer's data source has a different projection [NAD_1983_Lambert_Conformal_Conic] than the data frame's projection 20005 Annotation feature class contains a symbol in the symbol collection with the Rotate With Transform option disabled What do I do next? Do I ask the customer to rework their map data to not use VBScript? How much work are we asking the customer to do, to make their data work with ArcGIS runtime, when it worked just fine with the old VB control? I have to assume they have a reason for using label and annotation expressions. Are there alternatives that will work with 10.4 ArcGIS runtime, that will still work in their existing 10.0 ArcGIS environment? How do they make these changes? Is there some way of automating the transformation? Is there some alternative method for serving the map data that doesn't have these limits? If we have a local copy of ArcGIS running on the laptop, serving the data, could we display it using the Runtime .NET control?
... View more
06-21-2016
07:58 AM
|
0
|
2
|
1593
|
POST
|
I'm not seeing anything in any of the standard Windows event logs (nothing in Application, Security, Setup, or Forwarded Events.) And I don't see any custom event logs for ESRI.
... View more
05-10-2016
08:28 AM
|
0
|
0
|
845
|
POST
|
I uninstalled the free trial and installed the EDN package. Had the developed who had been running on our Single User ESRI license deauthenticate, ran through the authentication wizard and all looked fine. I've never had ArcMap successfully open, so I don't have any saved maps. I'm just selecting the program from the start menu.
... View more
05-09-2016
03:32 PM
|
0
|
0
|
845
|
POST
|
I tried deleting normal.mxt, and still had the problem. ArcMap recreated it, but still exited on startup. I then tried deleting the entire C:\Users\<user>\AppData\Roaming\ESRI\ directory, and that, also, behaved in the same way.
... View more
05-09-2016
07:47 AM
|
0
|
4
|
845
|
POST
|
I'm trying to get Arc Map 10.4 running, from a new installation of ArcGIS_Desktop on Windows 10. I'd initially installed the free trial, then uninstalled, and installed ArcGIS_Desktop_104_149411.exe. The installation worked fine, and the Authorization Wizard seems to have worked. I see EDN ArcGIS for Desktop Basic listed in ArcGIS Administrator, with version 10.1-10.4, marked as Installed, and Authorized, with an expiration of 01-Dec-2016. But when I run ArcMap 10.4, I get a splash screen showing the message "Loading Document..." for about 30 seconds, then it goes away. I filed a support ticket with ESRI last week, but have had no response. Is there some sort of log that ArcMap might be writing to, that would give me a hint as to what is going wrong? I've tried un-installing, and re-installing, and it's made no difference.
... View more
05-09-2016
06:53 AM
|
0
|
10
|
4081
|
POST
|
We have a WPF application, intended to be used in the field on laptops, that needs a mapping component. Currently, we're using Telerik's WPF controls, and specifically, their mapping control, which is displaying maps based on data retrieved from BING or from Open Street Map, depending upon the configuration. We have two new requirements: Some of our customers are ESRI customers, who want to be able to display their ArcGIS maps. Some of our customers need the ability to view maps when they do not have an internet connection. The two groups overlap, so we have some ESRI customers who need offline mapping, and we have some non-ESRI customers who need offline mapping. ESRI has an ArcGIS Runtime SDK for WPF that has offline capabilities - it can render maps installed as local services on the mobile. So we will definitely be exploring that approach. The question for now, though, is can we use the ArcGIS Runtime SDK for WPF controls and local services to provide offline maps for our non-ESRI customers. We have an ESRI license. Our customers do not. What licenses would our customers need to obtain in order to: Run our application with its embedded ArcGIS mapping control? Can we run the embedded ArcGIS mapping control against mapping sources other than ESRI? Against local WMS services, OSM, etc.? Run our application against ESRI local services map data that we included in our install? Update ESRI local services map data for themselves? In our ideal world, we'd just need to put a map file on the mobile (ESRI shapefile, GeoJSON, GML, XML, whatever) and have it be available to the mapping control in our application, and if the customer wanted to update the maps, they'd just generate the file with whatever software they used, and copy it into place. I don't expect the world to be that simple. We're considering alternatives. Copying tile cache directories, installing OSM in a box, etc. Running ESRI local services. ESRI will have to be part of our answer, because we have some customers who insist upon it, Whether it can be all of our answer depends upon how much cost that imposes upon the customer. Any idea where I can find out?
... View more
04-19-2016
08:39 AM
|
0
|
1
|
4941
|
POST
|
When I pass a LatLng object, I receive a "bbox must be specified" error. Any ideas as to what I should look at?
... View more
03-07-2016
09:12 AM
|
0
|
0
|
658
|
POST
|
I have a Leaflet map in which I am displaying an Esri ArcGIS REST layer, using L.esri.dynamicMapLayer(). The code that initializes this layer is passed the URL to the service and a comma-separated list of layers to be displayed - which service and which layers is configured by the user.
My task is to provide a means by which the user can click on the map and obtain feature information for the nearby facilities. I had been looking at L.esri.query(), which was simply inappropriate.
Looking at L.esri.DynamicMapLayer, I see that it has a function identify(), which should return an IdentifyFeatures object. But I'm not having any luck with using it.
Everything I try results in a "bbox must be specified" error.
The documentation for dynamicMapLayer is here: dynamic-map-layer.html
It includes:
Returns a new L.esri.services.IdentifyFeatures object that can be used to identify features on this layer. Your callback function will be passed a GeoJSON FeatureCollection with the results or an error.
dynamicMapLayer.identify()
.at(latlng, latlngbounds, 5)
.run(function(error, featureCollection)
{
console.log(featureCollection);
});
Note that .at() is called with a latlong object, a latlngbounds object, and "5".
But the documentation for the IdentifyFeatures object is here: identify-features.html
And it's documentation for at() is:
at( latlng) this Identifies feautres at a given
Only one argument. No second bounds argument, or third numeric argument, simply a LatLng. The LatLng links to the Leaflet code, indicating that it's an L.latLng object, containing a lat and a lng property.
The example code for IdentifyFeatures is even more confusing:
L.esri.identifyFeatures({
url: 'http://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer'
})
.on(map)
.at([45.543, -122.621])
.layers('visible:1')
.run(function(error, featureCollection, response){
console.log("UTC Offset: " + featureCollection.features[0].properties.ZONE);
});
Here, we're not passing a L.latLng object, we're passing an array.
What gives? How am I supposed to use this?
... View more
03-03-2016
03:04 PM
|
0
|
2
|
5570
|
Title | Kudos | Posted |
---|---|---|
1 | 07-07-2016 11:36 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|