I 've used Map1_TrackShapeFinished event on ServerSite to create a ruler. Now, I want to do that on ClientSite using Javascript.
Anybody can help me, pls!
I 've used Map1_TrackShapeFinished event on ServerSite to create a ruler. Now, I want to do that on ClientSite using Javascript.
Anybody can help me, pls!
Duong,
Here is the code you need. You can add your own event just like the following code commented.
<script type="text/javascript">
var OnMapCreating = function(map) {
var mapParser = Map1.GetMapParser();
mapParser.addControlsInJson = function(controls, onDrawEnd, onEditEnd) {
for (var key in controls) {
if (controls[key]) {
if (key == 'Modify') {
if (onEditEnd) {
controls[key].onModificationEnd = onEditEnd;
}
} else if (key != 'Normal') {
if (onDrawEnd) {
controls[key].featureAdded = onDrawEnd;
//controls[key].featureAdded = function() {
// alert('ok');
//}
}
}
this.map.addControl(controls[key]);
}
}
}
}
</script>
Thanks,
James
Dear James,
Pls, provide me more details infor. As me known, to create a ruler I need to do:
+ Get the long, lat values of started-point and ended-point
+ View the distance.
When using server-site, I used a client-button to setDrawMode(‘Line’), then used TrackShapeFinished event to process. I get features from EditOverlay and then get the distance.
@I have no more Experiences in hook client site of Mapsuite.
Duong,
I think there is a better way to help you do this if you want to create a ruler. There is a sample named “Get Distance Between Two Points” in our “HowDoISamples”, you could refer to it. It’s more easily to do this than JavaScript.
Thanks,
James