Select to view content in your preferred language

Control maptip location

917
6
04-13-2011 02:12 PM
DonFreeman
Emerging Contributor
Is there a way to control the popup location of a featurelayer maptip so that it does not extend off of the page? Usually it popsup to the lower right of the feature. Could we make it popup centered on the feature?
0 Kudos
6 Replies
DominiqueBroux
Esri Frequent Contributor
This blog post is talking about positionning maptips inside maps. It may be helpful : http://blogs.esri.com/Dev/blogs/silverlightwpf/archive/2010/09/30/How-to-keep-MapTips-in-the-Map.asp...
0 Kudos
DonFreeman
Emerging Contributor
This bog post is talking about positionning maptips inside maps. It may be helpful : http://blogs.esri.com/Dev/blogs/silverlightwpf/archive/2010/09/30/How-to-keep-MapTips-in-the-Map.asp...

Thanks Dominique. It looks like this might solve my problem. But as a beginner I'm not clear as to how to resolve the missing reference for  xmlns:local="clr-namespace:MapTipPosition" and where should I place the code behine code. Does it belong in the same code behind as the page containing the map, or in a separate class file? Does "MapTipPosition" refer to the name of the page its in?
Thanks for your help.
0 Kudos
DominiqueBroux
Esri Frequent Contributor

I'm not clear as to how to resolve the missing reference for xmlns:local="clr-namespace:MapTipPosition"

In this sample, MapTipPosition is the name of the project.
You don't need to create a new project, you can just include theMapTipPositionBehavior.cs source in your project and add the behavior to your map.
0 Kudos
DonFreeman
Emerging Contributor
In this sample, MapTipPosition is the name of the project.
You don't need to create a new project, you can just include theMapTipPositionBehavior.cs source in your project and add the behavior to your map.


OK, so let's see if I've got this right. The name of my project is "SLTrafficCounts". I have added a new class file named PositionMapTip.cs and the header info in that file looks like this.
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace SLTrafficCounts
{    
        public class PositionMapTip : Behavior<Map>
        {
            private Point _mousePos; // Track the position of the mouse on the Map

            /// Distance between the MapTip and the boundary of the map
            public double Margin { get; set; }

I then add this xaml code to the page containing the map:
 xmlns:local="clr-namespace:SLTrafficCounts"
            xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
. . . 
            <esri:Map x:Name="MyMap" Extent="748437,575771,1204687,267438" MouseClick="QueryPoint_MouseClick">
                <i:Interaction.Behaviors>
                    <local:SLTrafficCounts />
                </i:Interaction.Behaviors>


With this code the build produces two errors:
Error 1 Unexpected ATTRIBUTE in parse rule PropertyElement ::= . PROPERTYELEMENT Content? ENDTAG.. D:\WebDevelopment\SLTrafficCounts\SLTrafficCounts\Views\Map.xaml SLTrafficCounts

Error 2 The type 'local:SLTrafficCounts' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built. D:\WebDevelopment\SLTrafficCounts\SLTrafficCounts\Views\Map.xaml 109 22 SLTrafficCounts

So can you tell me what I have wrong?
Thanks
0 Kudos
DominiqueBroux
Esri Frequent Contributor

<local:SLTrafficCounts />


should be <local:PositionMapTip/> (name of the behavior)
0 Kudos
DonFreeman
Emerging Contributor
Dominique -
I got it working. Thanks
0 Kudos