/    Sign up×
Community /Pin to ProfileBookmark

Zooming a Image With a Function?

Hi!

I am trying to make a function that will zoom a image(of a map). What I want is a drop-down menu with the diffrent zoom factors that the user can select from, and when they select it it will pass a value to the function and the function will zoom it in or out depending on what the user selects(ex: 1 = 1x, 2 = 2x, 4 = 4x, etc.).

I am not asking that anybody does this for me, infact I would rather do it myself so I learn something in the process. [i]But[/i], I need to be pointed in the right direction.

Thanks for any and all help!
~ACA?

to post a comment
JavaScript

55 Comments(s)

Copy linkTweet thisAlerts:
@AnacondaAndyauthorMar 06.2004 — I forgot to attach the image...?

[upl-file uuid=62eccdeb-aab6-4b08-9be1-7fe35352f61b size=81kB]map.gif[/upl-file]
Copy linkTweet thisAlerts:
@VladdyMar 06.2004 — How about this for inspiration:

http://www.vladdy.net/Demos/ImageAdjustments.html
Copy linkTweet thisAlerts:
@Paul_JrMar 06.2004 — [i]Originally posted by Vladdy [/i]

[B]How about this for inspiration:

http://www.vladdy.net/Demos/ImageAdjustments.html [/B]
[/QUOTE]

Hey, that's really cool -- but the controls are [i]backwards![/i] :eek:
Copy linkTweet thisAlerts:
@VladdyMar 06.2004 — [i]Originally posted by Paul Jr [/i]

[B]Hey, that's really cool -- but the controls are [i]backwards![/i] :eek: [/B][/QUOTE]

Depends what you move: image or viewport... :p
Copy linkTweet thisAlerts:
@Paul_JrMar 06.2004 — [i]Originally posted by Vladdy [/i]

[B]Depends what you move: image or viewport... :p [/B][/QUOTE]

True, true. ?
Copy linkTweet thisAlerts:
@AnacondaAndyauthorMar 06.2004 — Nice! But I don't understand why there are two .js files. Also is there a way to make it into one function?
Copy linkTweet thisAlerts:
@VladdyMar 06.2004 — I did it as a demo for someone about 2 years ago. QueryString.js is there to implement the ability to specify the image URL in the query string - never got to that point.

I really do not remember the code so if you want to figure it out - you are on your own

?
Copy linkTweet thisAlerts:
@AnacondaAndyauthorMar 06.2004 — ok, here is what I have so far but it is not working...

Here is the javascript:

[code=php]
/*this is a array that contains the zoom powers that the user can select from a drop down list on the map*/
var zoomList = new Array(5)
zoomList[1] = 1 // 1 = 1x etc.
zoomList[2] = 2
zoomList[3] = 3
zoomList[4] = 4
zoomList[5] = 5

/*selectedZoom is the integer passed to the function signifying the zoom power that the user selects*/
function zoomMap(selectedZoom) {

/*this for "loop" looks through the zoomList array untill it maches the selectedZoom*/
for (var i = 0; i < zoomList.length; i++) {
if (zoomList[i] == selectedZoom) {
break
}
}

if (zoomList[i] == 1) {
document.mapPic.style.zoom = "1.0"
}

if (zoomList[i] == 2) {
document.mapPic.style.zoom = "2.0"
}

if (zoomList[i] == 3) {
document.mapPic.style.zoom = "3.0"
}

if (zoomList[i] == 4) {
document.mapPic.style.zoom = "4.0"
}

if (zoomList[i] == 5) {
document.mapPic.style.zoom = "5.0"
}
}
[/code]


and here is the html:

[code=php]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 TransitionalEN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<title>Zooming an Image With a Function</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/JavaScript" src="myZoomingFunction.js" ></script>
<link rel="stylesheet" type="text/css" src="basic.css" />
</head>


<body>

<form name="zoomForm">
<p>Please select <em>zoom power</em> to zoom in map:
<select name="pickZoom" onSelect="zoomMap(document.zoomForm.pickZoom.value)">
<option value="1">x1</option>
<option value="2">x2</option>
<option value="3">x3</option>
<option value="4">x4</option>
<option value="5">x5</option>
</select>
</form>

<img src="map.gif" name="mapPic" />
</body>
</html>
[/code]


Thanks for all help!?
Copy linkTweet thisAlerts:
@Paul_JrMar 06.2004 — Two things right off:
[list=1]
  • [*]Arrays start at 0, not 1.

    [b]zoomList[0] = 1 // 1 = 1x etc.

    zoomList[1] = 2

    zoomList[2] = 3

    zoomList[3] = 4

    zoomList[4] = 5 [/b]


  • [*]There is no CSS style "zoom".

    [b]If you look at Vladdy's example, what happens is the size of the image is increase for the zoom in, and decreased for the zoom out.[/b]

  • [/list]
    Copy linkTweet thisAlerts:
    @AnacondaAndyauthorMar 07.2004 — Ok, Thanks! I am doing something different now(I found out what I was doing would not work for what I need). I am getting a error when I run it...

    line 20 object expected.

    Could you point out what is wrong? thanks!

    [code=php]
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 TransitionalEN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>
    <title>Zooming an Image With a Function</title>

    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    </head>

    <script language="javascript/text">
    <!--

    /*zoomFactor is the integer passed to the function signifying the zoom power that the user selects*/
    function zoomMap(zoomFactor) {
    document.mapPic.style.zoom = zoomFactor
    }

    //-->
    </script>

    <body>

    <form name="zoomForm">
    <input type="button" name="zoom" value="Zoom" onClick="zoomMap(2.0)" />
    </form>

    <img src="globetrotter/map.gif" name="mapPic" />
    </body>
    </html>

    [/code]
    Copy linkTweet thisAlerts:
    @Paul_JrMar 07.2004 — O.o... there [i]is[/i] a CSS [FONT=courier new]zoom[/FONT] property? :eek: ?

    Anyhoo, I tried it out and it worked just fine for me. The error you are getting is due to the fact that your beginning [FONT=courier new]<script ... >[/FONT] tag is wrong.
    <i>
    </i>&lt;script language="javascript/text"&gt;

    It should be either [FONT=courier new]language="javascript"[/FONT] which is deprecated, or [FONT=courier new]type="text/javascript"[/FONT]. ?

    Also, one last thing, is you've got the [FONT=courier new]<script ... > </script>[/FONT] block after the closing [FONT=courier new]<head>[/FONT] tag, but [i]before[/i] the beginning [FONT=courier new]<body>[/FONT] tag. Generally, the [FONT=courier new]<script ... > </script>[/FONT] tags would go inside the [FONT=courier new]<head> </head>[/FONT] block.

    Cheers - ?
    Copy linkTweet thisAlerts:
    @AnacondaAndyauthorMar 07.2004 — 
    Also, one last thing, is you've got the <script ... > </script> block after the closing <head> tag, but before the beginning <body> tag. Generally, the <script ... > </script> tags would go inside the <head> </head> block.
    [/quote]


    I can't believe I did that!:rolleyes: lol..

    And thanks for finding the error!

    ~ACA?
    Copy linkTweet thisAlerts:
    @steelersfan88Mar 07.2004 — I have to thank AnacondaAndy for being one of the few left that make their code readable ([URL=http://forums.webdeveloper.com/showthread.php?s=&threadid=29230]as shown in this thread[/URL])

    And that is why it is so easy to debug his code, see the third reply for an example of code that could have been what he asked us to debug.

    I think more people should pay attention to things like this .... it will help out a lot in the long run!
    Copy linkTweet thisAlerts:
    @Paul_JrMar 07.2004 — [i]Originally posted by AnacondaAndy [/i]

    [B]I can't believe I did that!:rolleyes: lol..



    And thanks for finding the error!



    ~ACA? [/B]
    [/QUOTE]

    You're welcome! ?

    And, like Steelersfan88 said, thanks for making your code readable. ? :p
    Copy linkTweet thisAlerts:
    @AnacondaAndyauthorMar 07.2004 — ah, I am glad you like it...I am a perfectionest when it comes to coding...if it does not look just right it is no good to me because I spend 2hrs(not quite ?) looking for stuff that should only take 30secs to find...


    You're welcome!

    And, like Steelersfan88 said, thanks for making your code readable.
    [/quote]


    Np? ? ?
    Copy linkTweet thisAlerts:
    @Paul_JrMar 07.2004 — [i]Originally posted by AnacondaAndy [/i]

    [B]ah, I am glad you like it...I am a perfectionest when it come to coding...if it does not look just right it is no good to me because I spend 2hrs(not quite ?) looking for stuff that should only take 30secs to find [/B][/QUOTE]

    I know what you mean, I'm the same way. :p ?
    Copy linkTweet thisAlerts:
    @AnacondaAndyauthorMar 07.2004 — hehe, and be warned I'll be back with more questions soon about this function?

    Heres one now, it does not work in mozilla or mozilla firefox for me, any idea what is wrong??

    (as shown in this thread) [/quote]
    BTW, great post steelersfan!
    Copy linkTweet thisAlerts:
    @SamMar 07.2004 — perhaps its just me, but I can't find the zoom property in the css doc's, http://www.w3.org/TR/REC-CSS2/propidx.html
    Copy linkTweet thisAlerts:
    @Paul_JrMar 07.2004 — [i]Originally posted by AnacondaAndy [/i]

    [B]Heres one now, it does not work in mozilla or mozilla firefox for me, any idea what is wrong??[/B][/QUOTE]


    [i]Originally posted by samij586 [/i]

    [B]perhaps its just me, but I can't find the zoom property in the css doc's, http://www.w3.org/TR/REC-CSS2/propidx.html[/B][/QUOTE]


    Maybe that's why?

    I couldn't find it either, and that's why I was quite surprised when it "worked".
    Copy linkTweet thisAlerts:
    @SamMar 07.2004 — a ha! found it! but not on w3, it is in fact IE proprietery:
    [i]From http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/zoom.asp[/i]

    This feature requires Microsoft® Internet Explorer 5.5 or later. Click the following icon to install the latest version. Then reload this page to view the sample...

    ...This property is a Microsoft extension to Cascading Style Sheets (CSS)
    [/quote]
    Copy linkTweet thisAlerts:
    @Paul_JrMar 07.2004 — [i]Originally posted by samij586 [/i]

    [B]a ha! found it! but not on w3, it is in fact IE proprietery: [/B][/QUOTE]

    Ha! Should've figured!
    Copy linkTweet thisAlerts:
    @AnacondaAndyauthorMar 07.2004 — Bummer, now I'll have to try something else...
    Copy linkTweet thisAlerts:
    @PittimannMar 07.2004 — Hi!

    Excuse me, AnacondaAndy, for not replying to your pm; I was having guests. Now they left and I played a bit. I think, that should be enough for some inspiration.
    [code=php]
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 TransitionalEN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Zooming an Image With a Function</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <style type="text/css">
    <!--
    .imgD{
    width: 665px;
    height:403px;
    overflow:hidden;
    display:inline;
    position:absolute;
    }
    #mapPic{
    position:absolute;
    left:0px;
    top:0px;
    }
    -->
    </style>

    <script language="JavaScript" type="text/javascript">
    <!--
    var w=665
    var h=403
    var img;
    var left='0px';
    var top='0px';
    /*zoomFactor is the integer passed to the function signifying the zoom power that the user selects*/
    function zoomMap(zoomFactor) {

    img=document.getElementById('mapPic').style;
    img.left = left;
    img.top = top;
    img.width = w*zoomFactor+'px';
    img.height = h*zoomFactor+'px';
    }
    var moveIt;
    function moveL(){
    if (parseInt(img.width)>665&&Math.abs(parseInt(img.left))+665<parseInt(img.width)){
    img.left=parseInt(img.left)-3+'px';
    moveIt=setTimeout("moveL()",1);
    }
    }
    function moveR(){
    if (parseInt(img.width)>665&&(parseInt(img.width)-parseInt(img.left)>=parseInt(img.width))){
    img.left=parseInt(img.left)+3+'px';
    moveIt=setTimeout("moveR()",1);
    }
    }
    function moveU(){
    if (parseInt(img.height)>403&&Math.abs(parseInt(img.top))+403<parseInt(img.height)){
    img.top=parseInt(img.top)-3+'px';
    moveIt=setTimeout("moveU()",1);
    }
    }
    function moveD(){
    if (parseInt(img.height)>403&&(parseInt(img.height)-parseInt(img.top)>=parseInt(img.height))){
    img.top=parseInt(img.top)+3+'px';
    moveIt=setTimeout("moveD()",1);
    }
    }
    function stop(){
    clearTimeout(moveIt);
    }
    //-->
    </script>
    </head>
    <body>
    <form name="zoomForm">
    <input type="button" name="zoom" value="Zoom 2x" onClick="zoomMap(2)" />
    <input type="button" name="zoom" value="Zoom 3x" onClick="zoomMap(3)" />
    <input type="button" name="left" value="move left" onmouseout="stop();" onmouseover="moveL()" />
    <input type="button" name="right" value="move right" onmouseout="stop();" onmouseover="moveR()" />
    <input type="button" name="up" value="move up" onmouseout="stop();" onmouseover="moveU()" />
    <input type="button" name="down" value="move down" onmouseout="stop();" onmouseover="moveD()" />
    </form>
    <span id="imgDiv" class="imgD">
    <img src="map.gif" id="mapPic">
    </span>
    </body>
    </html>
    [/code]

    Tomorrow, I will add some more stuff to that...

    Cheers - Pit
    Copy linkTweet thisAlerts:
    @steelersfan88Mar 07.2004 — Thanks for the compliments about the post guys!

    Now lets all boo Pit because the code isn't readable like the rest of us. BOOO BOOO BOOO, j/k

    (EDIT: No clue why I wrote she, that's what i meant, no Pit, you don't deserve the boos.)
    Copy linkTweet thisAlerts:
    @PittimannMar 07.2004 — Hi!

    I absolutely accept the BOOO's, steelersfan88! I deserve them ?!!

    But don't call me she, please ?

    Cheers - Pit
    Copy linkTweet thisAlerts:
    @AnacondaAndyauthorMar 07.2004 — Thanks for doing it so fast Pit!! I don't quite understand all the code, but I am looking at it now and working it out.

    Would you mind putting comment tags after each line in the zoomMap() function explaning what they do, I understand most of it but I just need a little help with it so I can understand it enough to edit it. ?
    [code=php]
    function zoomMap(zoomFactor) {

    mapPic = document.getElementById('mapPic').style;
    mapPic.left = left;
    mapPic.top = top;
    mapPic.width = width * zoomFactor + 'px';
    mapPic.height = height * zoomFactor + 'px';
    }
    [/code]



    Also could you explane what

    -Math.abs

    -setTimeout

    ...do? Thanks!

    BTW, I edited the code so I could understand it, here it is...
    <i>
    </i>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 TransitionalEN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
    &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;

    &lt;head&gt;
    &lt;title&gt;Zooming an Image With a Function&lt;/title&gt;

    &lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;

    &lt;style type="text/css"&gt;
    &lt;!--
    .imgD
    {
    width: 665px;
    height:403px;
    overflow:hidden;
    display:inline;
    position:absolute;
    }

    #mapPic
    {
    position:absolute;
    left:0px;
    top:0px;
    }
    --&gt;
    &lt;/style&gt;

    &lt;script language="JavaScript" type="text/javascript"&gt;
    &lt;!--
    var width=665
    var height=403
    var mapPic;
    var left='0px';
    var top='0px';
    /*zoomFactor is the integer passed to the function signifying the zoom power that the user selects*/
    function zoomMap(zoomFactor) { <br/>
    mapPic = document.getElementById('mapPic').style;
    mapPic.left = left;
    mapPic.top = top;
    mapPic.width = width * zoomFactor + 'px';
    mapPic.height = height * zoomFactor + 'px';
    }

    var moveIt;
    function moveLeft(){
    if (parseInt(mapPic.width) &gt; 665 &amp;&amp; Math.abs(parseInt(mapPic.left)) + 665 &lt; parseInt(mapPic.width)) {
    mapPic.left = parseInt(mapPic.left) - 3 + 'px';
    moveIt = setTimeout("moveLeft()", 1);
    }
    }

    /*moves the image to the right*/
    function moveRight() {
    if (parseInt(mapPic.width) &gt; 665 &amp;&amp; (parseInt(mapPic.width) - parseInt(mapPic.left) &gt;= parseInt(mapPic.width))) {
    mapPic.left = parseInt(mapPic.left) + 3 + 'px';
    moveIt = setTimeout("moveRight()", 1);
    }
    }

    /*moves the image up*/
    function moveUp() {
    if (parseInt(mapPic.height) &gt; 403 &amp;&amp; Math.abs(parseInt(mapPic.top)) + 403 &lt; parseInt(mapPic.height)) {
    mapPic.top = parseInt(mapPic.top) - 3 + 'px';
    moveIt = setTimeout("moveUp()", 1);
    }
    }

    /*moves the image down*/
    function moveDown() {
    if (parseInt(mapPic.height) &gt; 403 &amp;&amp; (parseInt(mapPic.height) - parseInt(mapPic.top) &gt;= parseInt(mapPic.height))) {
    mapPic.top = parseInt(mapPic.top) + 3 + 'px';
    moveIt = setTimeout("moveDown()", 1);
    }
    }

    /*stops the scrolling across the image when the mouse moves off the image*/
    function stopScroll() {
    clearTimeout(moveIt);
    }
    //--&gt;
    &lt;/script&gt;
    &lt;/head&gt;


    &lt;body&gt;

    &lt;form name="zoomForm"&gt;
    &lt;input type="button" name="zoom" value="Zoom 2x" onClick="zoomMap(2)" /&gt;
    &lt;input type="button" name="zoom" value="Zoom 3x" onClick="zoomMap(3)" /&gt;
    &lt;input type="button" name="left" value="move left" onmouseout="stopScroll();" onmouseover="moveLeft()" /&gt;
    &lt;input type="button" name="right" value="move right" onmouseout="stopScroll();" onmouseover="moveRight()" /&gt;
    &lt;input type="button" name="up" value="move up" onmouseout="stopScroll();" onmouseover="moveUp()" /&gt;
    &lt;input type="button" name="down" value="move down" onmouseout="stopScroll();" onmouseover="moveDown()" /&gt;
    &lt;/form&gt;

    &lt;span id="imgDiv" class="imgD"&gt;
    &lt;img src="globetrotter/map.gif" id="mapPic"&gt;

    &lt;/span&gt;



    &lt;/body&gt;
    &lt;/html&gt;


    Thanks for all the help Pit!!!?
    Copy linkTweet thisAlerts:
    @steelersfan88Mar 07.2004 — Pit can help you, but a little explanation wouldn't hurt.

    setTimeout(...,...) simply tells the computer: "Hey wait this number of milliseconds, then go do this thing, then come right back to the next line of code."

    Math.abs(...) makes a number positive, just as would the following:[code=php]if(theNum < 0) {
    theNum *= -1 // multiply by negative 1
    }[/code]
    (Note my edit Pit)
    Copy linkTweet thisAlerts:
    @AnacondaAndyauthorMar 07.2004 — Pit can help you, but a little explanation wouldn't hurt. [/QUOTE]

    lol! sorry I did not mean that only pit could help...

    And thanks for explaning the two functions!?
    Copy linkTweet thisAlerts:
    @steelersfan88Mar 07.2004 — I knew what you meant ... i was just saying that if you need further help, ask Pit! glad you find the explanations quite useful
    Copy linkTweet thisAlerts:
    @PittimannMar 07.2004 — Hi!

    I am posting again, even though the questions you had concerning my BOOO-able ( :rolleyes: ) code have already been answered by steelersfan88 (Thanks! I was out for 2 hours and couldn't respond myself).

    Knowing that you sometimes start threads for learning purposes (which I appreciate very much!) and not for getting code to simply paste into a page, I was wondering, what else you might this zoom stuff to be able to. Example: I have already added some stuff to enable the user to click the image somewhere and the image will be zoomed with the clicked coordinate beeing centered.

    If you like, tell me, what other ideas you have in mind to extend the capabilities of the code...

    Cheers - Pit
    Copy linkTweet thisAlerts:
    @AnacondaAndyauthorMar 07.2004 — Thanks Pit! Yes there are more things I want to do with it. But I have to run right now so I'll try to post again sometime tonight when I get back. thanks again!

    BTW, your code was not BOOO-able, I loved it!
    Copy linkTweet thisAlerts:
    @PittimannMar 07.2004 — Hi!

    You're welcome!

    Don't run too fast. The boooh stuff was just a joke because of steelersfan88 comment :p. I had of course seen his thread and appretiate it and him, but I have to admit, that I am usually too lazy to write my code in the way suggested.

    That doesn't mean that I disrespect steelersfan88's suggestion!

    Cheers - Pit
    Copy linkTweet thisAlerts:
    @steelersfan88Mar 07.2004 — in other words, Pit is trying to say: "All hail me!", j/k. My code was exactly as you guys put it, a suggestion. But normally, this is better to help non-experts (in areas), not to put down anyone's coding ability. It might not be laziness, but understanding, that makes you do it that way Pit.

    That's whay HTML layouts are so poor, because so many people are enjoying its ease and *think* they understand it, while they should see the thread i previously posted, and make it so they can indeed understand it.

    It's great that there is so little fighting here going on anymore, that we can all get along. (just to remember Dave and Charles fighting all the time makes me sick). Note on Dave: I did contact him by email and he specifically stated:[i]Originally emailed by Dave Clark[/I]

    I was not even reprimanded by the administration for any of my actions. None of my super-moderator powers were taken from me until one member of the administration got upset because I used my super-moderator powers to mass-delete about 5,000 of my posts (i.e., from all forums except the ASP forum). At that point, he reduced my powers to just an ordinary moderator. I resented that (since I had done nothing to deserve such treatment -- even ordinary members have the power to delete their own posts), so I proceeded to manually delete all of my remaining posts one-by-one. That is when I left.

    I harbor no ill feelings toward the forums or the administrators. I wish that everyone there will find the assistance they need. But, I will not return. I just can't sit idly by and watch one member castigating another member without provocation. Yes, I used to castigate certain members up one side and down the other (and not just on my own behalf) -- but that was always after provocation. I'm sure that such treatment of others continues. At least, without me there, it is a little quieter (I hope). ;-)[/QUOTE]Just thought I'd post that since somehow I took us sooooo offtrack.
    Copy linkTweet thisAlerts:
    @PittimannMar 07.2004 — Hi!

    steelersfan88, I was thinking about posting to your thread about the legibility of code etc., but I decided to "remain here". I really hope, you don't misunderstand me (sometimes I have doubts because of the fact that English is a foreign language for me). What I wanted to say in my last previous post is:

    The "boooh-stuff" really was a joke. I didn't feel offended by you when you boohed (no need to edit your post! ?) - you were right; and I didn't want to offend you!!!

    I took your thread really serious and I appreciate, what you pointed out there (and in this thread as well, of course). The thing for me is just:

    Sometimes it takes a long time to write stuff for a reply and it saves me time, not to comment code I want to post. But I would always respond, if somebody wants me to explain the code I posted.

    I don't want this post to grow too much, but I hope, you got me. I honestly respect you!

    Cheers - Pit
    Copy linkTweet thisAlerts:
    @steelersfan88Mar 07.2004 — it seems that you, Pit, are concerned that I'm offended by you? You are completely wrong, I've never had a prblem with you and my previous posts are, like your, jokes (except for Dave's reply and the stuff about fighting). I understood everything you did and don't feel at all disrespected or devalues or anything.

    I knew English wasn't your first language because you say you live in Germany, not because of the way you type; there are some people on these forums that really can't type english (and i think for its their first language).

    I just wanted you to know that I didn't feel there was a reason for making your last reply because I did understand everything you have previously posted. And I don't feel badly if someone does not follow the rules I previously posted because it os not a requirement, just an assistance to help beginners out; that's why I write much of my code of this forum like that, in case I'm talkin to beginners.

    And just so you understood me clearly, I simply stated that the reason you may not comment what you do is because you understand what your doing. The reason I do is because i don't know if the person who will receive the script will understand what it does. Just to clear things out, its all cool, and always shall be ?!
    Copy linkTweet thisAlerts:
    @PittimannMar 07.2004 — ?

    Cheers - Pit
    Copy linkTweet thisAlerts:
    @AnacondaAndyauthorMar 08.2004 — Hi!

    I though I'd let you know, I am working on this for someone, but it is mostly to learn. And I will give you the credit when I send it to him. ?


    This is going to be a guest map where people can drag a little icon(of a person) and place it where they live. Here is a link...

    --> http://globetrotter.sourceforge.net/demo/

    But my part in the project is to create a function(I am not being paid) that will zoom the map by an integer passed to it and keep the icons in the right postion. The Math for this should be:
    [code=php]
    x_coordinate_of_icon = x_coordinate_of_icon * zoom_factor
    y_coordinate_of_icon = y_coordinate_of_icon * zoom_factor
    [/code]


    I hope I explaned it well enough.

    Thanks for any help!

    ~ACA
    Copy linkTweet thisAlerts:
    @steelersfan88Mar 08.2004 — i would have no clue going about this (sorry for letting you down guys .... and for talking to pit on your thread). i would not even know where to get started.(except for readin thru this thread over and over)
    Copy linkTweet thisAlerts:
    @AnacondaAndyauthorMar 08.2004 — [i]Originally posted by steelersfan88 [/i]

    [B]i would have no clue going about this (sorry for letting you down guys .... and for talking to pit on your thread). i would not even know where to get started.(except for readin thru this thread over and over) [/B][/QUOTE]


    NP?
    Copy linkTweet thisAlerts:
    @SamMar 08.2004 — not sure if this will help, but I started a script (and didn't even near finishing it)[URL=http://www.medford.k12.or.us/sample/]here[/URL]

    If i remember right, gecko will come up blank, but IE works alright, check it out and see if its any help
    Copy linkTweet thisAlerts:
    @AnacondaAndyauthorMar 08.2004 — Pit already gave me the zooming part, but thanks anyway!
    Copy linkTweet thisAlerts:
    @AnacondaAndyauthorMar 09.2004 — This script does no work on opera right, it takes about 15seconds to zoom after i click zoom, any idea why?

    Thanks!

    ACA
    Copy linkTweet thisAlerts:
    @SamMar 09.2004 — does this happen every time, or just after a couple of times?

    As the zoom factor gets larger and larger, the longer it takes to render, since a lot of the rendering is taking place outside the viewport
    Copy linkTweet thisAlerts:
    @AnacondaAndyauthorMar 09.2004 — Every time, and the function curently only has one zoom factor. But you may be right, Thanks! Sorry, I forgot to post the code?

    I am not going to post the whole document...
    [code=php]
    <style type="text/css">
    <!--
    .imgD
    {
    width: 665px;
    height:403px;
    overflow:hidden;
    display:inline;
    position:absolute;
    }

    #mapPic
    {
    position:absolute;
    left:0px;
    top:0px;
    }
    -->
    </style>

    <script language="JavaScript" type="text/javascript">
    <!--
    var width=665
    var height=403
    var mapPic;
    var left='0px';
    var top='0px';

    /*zoomFactor is the integer passed to the function signifying the zoom power that the user selects*/
    function zoomMap(zoomFactor) {

    mapPic = document.getElementById('mapPic').style;
    mapPic.left = left;
    mapPic.top = top;
    mapPic.width = width * zoomFactor + 'px';
    mapPic.height = height * zoomFactor + 'px';
    }
    //-->
    </script>
    </head>


    <body>

    <form name="zoomForm">
    <input type="button" name="zoom" value="Zoom Map" onClick="zoomMap(2)" />
    <input type="button" name="reset" value="Reset" onClick="zoomMap(1)" />
    </form>

    <span id="imgDiv" class="imgD">
    <img src="globetrotter/map.gif" id="mapPic">

    </span>
    [/code]
    Copy linkTweet thisAlerts:
    @AnacondaAndyauthorMar 09.2004 — 
    I was wondering, what else you might this zoom stuff to be able to. Example: I have already added some stuff to enable the user to click the image somewhere and the image will be zoomed with the clicked coordinate beeing centered.
    [/quote]


    Could you post that code so I can study it? I can't think on anything else to do with the zooming thing, do you have any ideas?? I'd welcome ideas!

    Thanks again!(I know, I know, i'm starting to sound like a broken record ; ))

    ACA
    Copy linkTweet thisAlerts:
    @SamMar 09.2004 — the link I gave centers on the point the user clicks
    Copy linkTweet thisAlerts:
    @SamMar 09.2004 — [i]Originally posted by AnacondaAndy [/i]

    [B]Every time, and the function curently only has one zoom factor. But you may be right, Thanks! Sorry, I forgot to post the code?



    I am not going to post the whole document...

    [code=php]
    <style type="text/css">
    <!--
    .imgD
    {
    width: 665px;
    height:403px;
    overflow:hidden;
    display:inline;
    position:absolute;
    }

    #mapPic
    {
    position:absolute;
    left:0px;
    top:0px;
    }
    -->
    </style>

    <script language="JavaScript" type="text/javascript">
    <!--
    var width=665
    var height=403
    var mapPic;
    var left='0px';
    var top='0px';

    /*zoomFactor is the integer passed to the function signifying the zoom power that the user selects*/
    function zoomMap(zoomFactor) {

    mapPic = document.getElementById('mapPic').style;
    mapPic.left = left;
    mapPic.top = top;
    mapPic.width = width * zoomFactor + 'px';
    mapPic.height = height * zoomFactor + 'px';
    }
    //-->
    </script>
    </head>


    <body>

    <form name="zoomForm">
    <input type="button" name="zoom" value="Zoom Map" onClick="zoomMap(2)" />
    <input type="button" name="reset" value="Reset" onClick="zoomMap(1)" />
    </form>

    <span id="imgDiv" class="imgD">
    <img src="globetrotter/map.gif" id="mapPic">

    </span>
    [/code]
    [/B][/QUOTE]

    I'm not sure if this will help, but why not use with()? Its slightly more clean than what you have now.

    here's an example:
    [code=php]
    <script language="JavaScript" type="text/javascript">
    <!--
    var picwidth=665
    var picheight=403
    var picleft='0px';
    var pixtop='0px';

    /*zoomFactor is the integer passed to the function signifying the zoom power that the user selects*/
    function zoomMap(zoomFactor) {

    zoomFactor=parseInt(zoomFactor); //perhaps this is what is slowing opera down (it can't figure out what type of data zoomFactor is)
    with(document.getElementById('mapPic').style)
    {
    left= picleft;
    top = pictop;
    width = picwidth * zoomFactor + 'px';
    height = picheight * zoomFactor + 'px';
    }
    //-->
    </script>
    [/code]
    Copy linkTweet thisAlerts:
    @PittimannMar 09.2004 — Hi!

    Here's what you asked me to post in your previous post.

    I had checked out the link you posted (with all these tiny people). To get the draggable icon onto the map and keep it's position while zooming would be ok, but so far there are already more than 170 "people" on that map. If they all will have to be moved, that is going to be a slow, slow script.

    Can you please describe more specifically, what need's to be done on the icon stuff?

    Cheers - Pit

    Btw - can you imagine that I reduced the file size of this globetrotter page by 80 kilobytes only removing unnecessary spaces?

    [upl-file uuid=17580e9f-346c-4041-9337-f94c03daf586 size=5kB]anacondazoom.txt[/upl-file]
    Copy linkTweet thisAlerts:
    @AnacondaAndyauthorMar 09.2004 — samij586,

    Thanks for the help! That cleans it up a bit. I'll test it some more as soon as I have time.

    pit,

    Thanks for posting that! It is exacily what I was looking for! I had another question, is there a way to click on a button that will change the mouse to a magnifing glass and then you can click on the image and it will zoom it?

    About the script being slow, I was thinking about that myself, but I can't think of a better way to do it. What I have to do is move all the people with the map so they stay in the right place on the map...but I just found out that will take php and javascript, so I am not going to worry about that right now. Thanks anyway : )


    Btw - can you imagine that I reduced the file size of this globetrotter page by 80 kilobytes only removing unnecessary spaces?
    [/quote]

    I don't doubt it! ?

    Cheers,

    Anaconda
    Copy linkTweet thisAlerts:
    @PittimannMar 09.2004 — Hi!

    Concerning the magnifying glass:

    So far "we" never talked about the way, you want things to be handled. I would suggest that you point out, how the user should get into zoom mode (in, out, buttons, radio buttons - whatever). Then it will be easy to add a magnifying glass with a "+" sign in it for zooming in and with a "-" for zooming out.

    samij586 already uses that feature in the code, he/she posted previously. In css, you can define your own cursors (make the cursor images, load them up somewhere and assign the cursor in your css).

    If you like, have a look at this:

    http://www.w3.org/TR/REC-CSS2/ui.html#propdef-cursor

    You will have to deal with the example above the beginning of the next chapter.

    If you need a hand, just post again...

    Cheers - Pit
    Copy linkTweet thisAlerts:
    @SamMar 09.2004 — note: my cursor code never fully worked, and I still can't figure out why, try clicking the zoom in button, then the zoom out button, then the zoom in button again... for some reason it dies.

    As to the people shifting aspect, I would suggest breaking the map into regions on the first zoom, and only draw that region, that way you don't have to worry about as many people
    Copy linkTweet thisAlerts:
    @AnacondaAndyauthorMar 30.2004 — Sorry guys, I did not see your last 2 post.

    Pit, about the using css to change the cursor, thanks I'll try it! I guess I'll use a button to get into zooming mode.

    I am having some problems in firefox, it is slower and kinda chopy moving back and forth, can you add a function that test if it is firefox and make it move faster if it is?

    here is the link: [URL=http://users.iglide.net/tonnesenteam/tirians/anacondazoom.html]Zooming Function[/URL]

    As to the people shifting aspect, I would suggest breaking the map into regions on the first zoom, and only draw that region, that way you don't have to worry about as many people[/quote]
    samij586, thanks, that is a great idea!!
    Copy linkTweet thisAlerts:
    @steelersfan88Mar 30.2004 — looks good, and works! there are errors when loading:
    [list]
  • [*]btrue is undefined (line 120)

  • [*]object required (line 100)

  • [/list]


    Nice work!
    Copy linkTweet thisAlerts:
    @AnacondaAndyauthorMar 30.2004 — thanks! I look into it.

    Why can't I get it to validate? I don't understand the errors.

    Here is the link:

    [URL=http://validator.w3.org/check?uri=http%3A%2F%2Fusers.iglide.net%2Ftonnesenteam%2Ftirians%2Fanacondazoom.html&charset=%28detect+automatically%29&doctype=%28detect+automatically%29&verbose=1]Validate (x)HTML -- I wish[/URL]
    ×

    Success!

    Help @AnacondaAndy spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.5,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,

    tipper: @Samric24,
    tipped: article
    amount: 1000 SATS,
    )...