I tried to use Static Overlay Api to create custom copyright text statically displayed on all map. To do this I tried to call both STO creation :
But both raised an exception: COM exception, HRESULT E_FAIL
I don't know what is the problem since there is no any example in API reference about how to use them.
Could anyone describe STO usage in more detail than API reference?
Hi. The function CreateDprRenditionStaticTopOverlay needs a DPR rendition as its first parameter. You can specify a local path or a URL to a DPR file/rendition. This is probably why it fails.
If you want to display static text, I think you should instead use CreateEditableStaticTopOverlay . Looking at the documentation, that function requires 7 parameters like this:
CreateEditableStaticTopOverlay (isViewRotationDependent, predefinedScreenPosition, pixelWidth, pixelHeight, originOffsetX, originOffsetY, requestedOverlayIdx)
An example call would then be:
CreateEditableStaticTopOverlay(FALSE, 9, 100, 12, 10, 10, &OverlayIdx);
OverlayIdx is the index of the overlay you just created, as a return value. You will then use that index in the element creation calls (AddStaticTopOverlayTextElement, etc).
hope this helps,
Martin
Hi,
Here is an javascript example to display text as static top overlay in the Map Viewer:
var overlayId = document.MapViewerControl.CreateEditableStaticTopOverlay(5, 300, 30, 0, 0);var rendId = document.MapViewerControl.AddStaticTopOverlayTextElement(overlayId, document.MapViewerControl.VBArrayFromJavaScriptArray(new Array(0,0)), "Copyright 2011", "Aerial", 30, 0x0000ff, 1.0, 2);
var overlayId = document.MapViewerControl.CreateEditableStaticTopOverlay(5, 300, 30, 0, 0);
var rendId = document.MapViewerControl.AddStaticTopOverlayTextElement(overlayId, document.MapViewerControl.VBArrayFromJavaScriptArray(new Array(0,0)), "Copyright 2011", "Aerial", 30, 0x0000ff, 1.0, 2);
Sylvain
By the way, let me apologize for posting the wrong function signature. I think Sylvain has it right here. I looked it up in the wrong documementation...
This is exactly what I tried. It always throws an exception: H_RESULT E_FAIL. I tried it with many different parameters to test but always got an exception.
Did you load a map definition prior to use the top overlay methods? If a map is not loaded, I also get an error.