Select to view content in your preferred language

Urgent: How to fix infowindow to a point so when map drag it won't move

2611
8
04-10-2011 04:35 AM
Sophialim
Emerging Contributor
How to fix a infowindow or a info template to a point so that when i drag the map the infowindow will no change place or move ...what is the code...and where shld i place it at?
this is my code :
var stX             =   "23319.3347409758";
    var stY             =   "28825.7191286444";
    var pt= new esri.geometry.Point(stX,stY,map.spatialReference);
    //var strImage = "http://www.rw-designer.com/i/download48b.png";
var symbol = new esri.symbol.PictureMarkerSymbol(strImage, 25,25);
    var attr = {"PlaceName":"Peranakan musem of Singapore","PlaceAddr":"addr"};
    var infoTemplate = new esri.InfoTemplate();
    infoTemplate.setTitle("Building Name:");
    infoTemplate.setContent(getInfoContent);
    var graphic = new esri.Graphic(pt,symbol,attr,infoTemplate);
    gLayer.add(graphic);
    }

   function getInfoContent(graphic){
   var bc = new dijit.layout.BorderContainer({style: "font-size: 11pt; height: 520px; width:493px; background: #CCFFFF;"});
   var c1 = new dijit.layout.ContentPane({
   region: "top",
   style: "height: 20px width: 100%",
   content: "hello"
   });
   bc.addChild(c1);
  

   //make a tab container
   var tc = new dijit.layout.TabContainer({
   region: "center",
   style: "height: 65%; width: 100%;  "
   }, dojo.create("div"));

    //display attribute information
    var cp1 = new dijit.layout.ContentPane({
//style: " background-color: red; ",
          title: "<font color= #E4287C><b>detail</font> ",
          content: "sfdfsdfsdf"
        });
    tc.addChild(cp1);
bc.addChild(tc);
return bc.domNode;
}
dojo.addOnLoad(addSymbol);
0 Kudos
8 Replies
MatthewLawton
Deactivated User
Are you looking for something like this?

map.infoWindow.show(map.position,map.getInfoWindowAnchor(map.position));

That should anchor the info window to a feature position on the map. Or you can anchor it to a mouse click, like this:

map.infoWindow.show(evt.screenPoint,map.getInfoWindowAnchor(evt.screenPoint));
0 Kudos
Sophialim
Emerging Contributor
Are you looking for something like this?

map.infoWindow.show(map.position,map.getInfoWindowAnchor(map.position));

That should anchor the info window to a feature position on the map. Or you can anchor it to a mouse click, like this:

map.infoWindow.show(evt.screenPoint,map.getInfoWindowAnchor(evt.screenPoint));


how to use this when i want to fix to a position?
cause what i need is when i click on the icon i need to pop up the infowindow but at the same time the icon will move to the side so that the infowindow will be fix until almost the whole map sia...but at the side still can see the icon on the map
0 Kudos
SiqiLi
by Esri Contributor
Esri Contributor
For the infoWindow.show(point, placement) method, the point parameter is an esri.geometry.Point object. It is defined by the x y coordinates of the location. Therefore, it always fix to that location on the earth, not the screen. When the map is moved, the location is moved, and the infowindow is moved too.

You may want to try some other control, e.g. floating window or others,  instead of infowindow.
0 Kudos
MatthewLawton
Deactivated User
If you are trying to create an InfoWindow that is independent of the map and fixed on your screen, you may want to use a different Dojo Dijit that is outside of the map functionality. You can still populate it with the map derived data, but it will not be anchored to the map. I don't know the exact details of how to implement this, but I have an application where I populated the map attribute data into a DIV on the side of my map and it was not that difficult to accomplish. I imagine it would shouldn't be too difficult to have a fixed popup appear, especially if you can find a Dojo Dijit that already exists for this.

Good Luck!
0 Kudos
Sophialim
Emerging Contributor
For the infoWindow.show(point, placement) method, the point parameter is an esri.geometry.Point object. It is defined by the x y coordinates of the location. Therefore, it always fix to that location on the earth, not the screen. When the map is moved, the location is moved, and the infowindow is moved too.

You may want to try some other control, e.g. floating window or others,  instead of infowindow.


but if the placement is the  archo to the map is it? if i want to click on the icon and the icon move to the side of the map and the infowindow pop up and take up almost half the map view...and the infowindow is fix...how can i do it?
0 Kudos
Sophialim
Emerging Contributor
If you are trying to create an InfoWindow that is independent of the map and fixed on your screen, you may want to use a different Dojo Dijit that is outside of the map functionality. You can still populate it with the map derived data, but it will not be anchored to the map. I don't know the exact details of how to implement this, but I have an application where I populated the map attribute data into a DIV on the side of my map and it was not that difficult to accomplish. I imagine it would shouldn't be too difficult to have a fixed popup appear, especially if you can find a Dojo Dijit that already exists for this.

Good Luck!


so can teach miie tat method i want to see can work anot and what is the dojo diji...cus i use the border container, and tab container and the content pane....
cus i want to click on the icon and the icon move to the side of the map and the infowindow pop up and take up almost half the map view...and the infowindow is fix...how can i do it?
0 Kudos
SiqiLi
by Esri Contributor
Esri Contributor
but if the placement is the  archo to the map is it? if i want to click on the icon and the icon move to the side of the map and the infowindow pop up and take up almost half the map view...and the infowindow is fix...how can i do it?


The placement parameter means the placement of the InfoWindow with respect to the graphic.  It is relative to the location of your icon. It just means put the inforwindow on the UPPERRIGHT side or other side of the icon. Not the placement on the screen.

http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi_start.htm#jsapi/infowindow.htm#show

Like the answer from mflawton, you may need to find another Dojo Diji control. Maybe a Javascript popup box or other better one.
http://www.w3schools.com/JS/js_popup.asp
0 Kudos
Sophialim
Emerging Contributor
The placement parameter means the placement of the InfoWindow with respect to the graphic.  It is relative to the location of your icon. It just means put the inforwindow on the UPPERRIGHT side or other side of the icon. Not the placement on the screen.

http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi_start.htm#jsapi/infowindow.htm#show

Like the answer from mflawton, you may need to find another Dojo Diji control. Maybe a Javascript popup box or other better one.
http://www.w3schools.com/JS/js_popup.asp


what is the the dojo diji tat you two say? cause i gt use the border container and tab container dojo diji control
0 Kudos