Email conversation
From | Lai D WC |
To | Me |
Subject | How to highlight a point |
Date | 25 May 2005 00:57 |
Hi there,
I have a problem of highlighting a point in amap when the user input the text
boxes provided such as current location text boxes. I do not hav a clue at all.
Would you help me with this because the due date for this is on friday(27th of
May). For this, I also need to draw a path between those 2 spots.
Thank you so much and looking forward to hear from you.
regards,
D.L
From | Me |
To | Lai D WC |
Subject | Re: How to highlight a point |
Date | 25 May 2005 15:14 |
> I have a problem of highlighting a point in amap when the user input
> the text boxes provided such as current location text boxes.
Assuming you are using JavaScript, dynamically create a positioned element.
If you are using a server side script, you would need to create something
similar and output the required HTML.
<div id="bar" style="position: relative;">
<img src="map.png" alt="A map of the area">
</div>
<form method="post" action="">
<input type="text" name="fromX">
<input type="text" name="fromY">
<input type="text" name="toX">
<input type="text" name="toY">
<input type="button" value="Plot" onclick="draw(this.form)">
</form>
function draw(oForm) {
var oFromX = parseInt(oForm.fromX.value);
if(isNaN(oFromX)) { return; }
...
//...do something here to calculate the desired positions
...
var foo = document.createElement('div');
foo.style.position = absolute;
foo.style.left = fromPosX+'px';
foo.style.top = fromPosY+'px';
foo.style.height = '1px';
foo.style.width = '1px';
foo.style.overflow = 'hidden';
foo.style.backgroundColor = 'red';
document.getElementById('bar').appendChild(foo);
... then do the same again to insert the other point ...
}
> For this, I also need to draw a path between those 2 spots.
much harder. HTML cannot draw lines on its own (SVG can, but that is not
easy to insert onto a page like this, and is not available in all browsers).
The way most people draw a line is to use a for loop to create several
positioned elements (as above), and calculate their positions so that they
line up to look like a line. Very hard to make it look perfect, but it is
the easiest way to get a proper cross browser effect.
Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/