Hi all,

I need to create a button that get the coodenadas a point. Unfortunately is
the first time that I use the mapbuilder and I have trouble to create this
button.
I wish that you say step by step how to create this button.

I tried to create, but unfortunately the button does not appear in the
button bar.

I shall step by step what I tried to do:

1) Get a file (CoordsPopup.js) with the following javascript content below
and put in the directory mapbuilder/lib/widget

/*
License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
Dependancies: Context
$Id: WfsGetFeature.js 1779 2005-11-01 13:28:05Z cappelaere $
*/

// Ensure this object's dependancies are loaded.
mapbuilder.loadScript(baseDir+"/tool/ButtonBase.js");
/**
 * Builds then sends a WFS GetFeature GET request based on the WMC
 * coordinates and click point.
 * @constructor
 * @base ButtonBase
 * @author Cameron Shorter
 * @param widgetNode The XML node in the Config file referencing this
object.
 * @param model The Context object which this tool is associated with.
 */
function CoordsPopup(widgetNode, model) {
  // Extend ButtonBase
  ButtonBase.apply(this, new Array(widgetNode, model));

  // override default cursor by user
  // cursor can be changed by spefying a new cursor in config file
  this.cursor = "crosshair";

  /**
   * Open window with query info.
   * This function is called when user clicks map with Query tool.
   * @param objRef      Pointer to this GetFeatureInfo object.
   * @param targetNode  The node for the enclosing HTML tag for this widget.
   */
  this.doAction = function(objRef,targetNode) {
    if (objRef.enabled) {
      extent=objRef.targetModel.extent;
      point=extent.getXY(targetNode.evpl) + "";
      pointx = point.substring(0,point.indexOf(","));
      pointy = point.substring(point.indexOf(",") + 1, point.length);
      pointx = pointx.substring(0,pointx.indexOf("."));
      pointy = pointy.substring(0,pointy.indexOf("."));
      popup = window.open
("","pointLocation","height=120,width=300,dialog=yes,modal=yes,top=200,left=200");
      popup.document.open();
      popup.document.write('<html><head><title>Point
Location</title></head><body><table size="100%" border="0"><tr><td>The
selected point\'s coordinates are:<br/><br/>X:' + pointx + "<br/>Y:" +
pointy);
      popup.document.write("</td></tr></table></body></html>");
      popup.document.close();
    }
  }


  /**
   * Register for mouseUp events.
   * @param objRef  Pointer to this object.
   */
  this.setMouseListener = function(objRef) {
    if (objRef.mouseHandler) {
      objRef.mouseHandler.model.addListener('mouseup',objRef.doAction
,objRef);
    }
  }
  config.addListener( "loadModel", this.setMouseListener, this );
}



2) Added the code in config.xml
<widgets>
...
<CoordsPopup id="coords">
        <buttonBar>mainButtonBar</buttonBar>
        <targetModel>mainMap</targetModel>
        <mouseHandler>mainMouseClick</mouseHandler>
        <class>RadioButton</class>
        <selected>true</selected>
        <enabledSrc>/images/QueryEnable.png</enabledSrc>
        <disabledSrc>/images/QueryDisable.png</disabledSrc>
</CoordsPopup>
...
</widgets>

3)Added the code in mapbuilder/lib/schemas/config.xsd

<xs:complexType name="CoordsPopupType"> <!--adicionado-->
      <xs:annotation>
          <xs:documentation>Geting coodenates</xs:documentation>
      </xs:annotation>
      <xs:complexContent>
          <xs:extension base="mb:AbstractButtonType" />
      </xs:complexContent>
  </xs:complexType>
    ......
 <xs:complexType name="widgetsType">
    <xs:choice maxOccurs="unbounded">
      ....
    <xs:element name="CoordsPopup" type="mb:CoordsPopupType"/>
      ....
    </xs:choice>
  </xs:complexType>

4) In widgetText.xml added
...
<CoordsPopup>
        <title>Geting coodinates</title>
    </CoordsPopup>
...


====================================================


Unfortunately my button not appear! :(
What's happening?


Sorry for my bad English!
Thanks

André
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Mapbuilder-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mapbuilder-users

Reply via email to