[Chameleon] JSAPI newbie questions

Ken Sanderson ken at rockies.ca
Sun Jul 11 21:03:04 EDT 2004


Hello all.

Now that I have chameleon up and running I thought the best way to get
things rolling on the learning curve was to dive in and use it for an
upcoming project. The project has the requirement of a tool where the
user clicks on the map, I get the coordinates for that click, and then I
go and do something with those coords. Fairly straight forward.

After reading the docs on widgets and JSAPI I decided likely the JSAPI
was a good way to go and further decided to start off by implimenting
the example in the JSAPI docs.

So first I added the two lines up below the rest of the shared
resources:

<CWC2 TYPE="SharedResource" NAME="CWCJSAPI"/>
<CWC2 TYPE="CWCJSAPI" Debug="false"/>

This I gather should tell things that I am using JSAPI.

I then added the event register to the myOnLoad() function like:

function myOnLoad()
{
  CWC2OnLoadFunction();
  goCWCApp.RegisterEvent( MOUSE_CLICKED,
                        "myMouseClicked");
}

Then I pasted in the myMouseClicked function from the JSAPI docs, like:

function myMouseClicked()
{
  oMap = goCWCApp.oMap;
  mousePos = "(" + oMap.mouseclick[0] + ","
                 + oMap.mouseclick[1] + ")";
  alert("mouse clicked at " + mousePos);
}

So now my question. What have I done wrong or missed doing? By added the
above it more or less breaks the page. Is it because I have not set it
to tell the other widgets to not operate, ie if the tool selected is
zoomin, then its going to zoomin as well as my little function?
Obviously I am going to want to change it so it only does my function,
but can you have both if you wanted too?

Any suggestions appreciated, as well as tips, tales and stories from
those more experienced with the JSAPI.

Thanks,

Ken Sanderson
Miistakis 






More information about the Chameleon mailing list