473,406 Members | 2,894 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Image map problem

I have an image scrolling in a viewport for a panoramic image
viewer. The viewport can be resized to several set resolutions so people
can adjust the size according to their bandwidth. There are hotspots on
the image which have been defined using an image map. This map is
generated in javascript using the following code (in the object 'tour.'):

makeImageMap: function() {
// creates an HTML nodeset which is an imagemap for the current view.
//alert("making image map");
if (tour.imageMap!=0) {
// delete the old image map
tour.panoInnerDiv.removeChild(tour.imageMap);
}
tour.imageMap=document.createElement("map");
tour.imageMap.name="panoMap";
tour.imageMap.style.zIndex="3";
dojo.dom.insertAtPosition(tour.imageMap,tour.panoI nnerDiv,"first");
for (var i=0; i<tour.curView.links.length; i++) {
var link=tour.curView.links[i];
//alert("found link:"+link.id);
for (var j=0; j<link.areas.length; j++) {
//alert("found area");
var mapArea=document.createElement("area");
var area=link.areas[j]; // area is an array of point objects.
var pointStr="";
for (var k=0; k<area.length; k++) {
var point=area[k];
if (pointStr!="") { pointStr += ","; };
var mapX=tour.resolution*tour.panoImg.ratio*point.pan;
var mapY=tour.resolution*point.height;
pointStr+=mapX.toFixed(0)+","+mapY.toFixed(0);
// alert("adding point with pan:"+point.pan+",height:"+point.height);
}
mapArea.shape="poly";
mapArea.nohref="";
mapArea.coords=pointStr;
mapArea.style.cursor="hand";
//alert("pointStr:"+mapArea.coords);
mapArea.id=link.type+"--"+link.id+"--"+j;
//var id=tour.getAreaId(mapArea);
dojo.dom.insertAtPosition(mapArea,tour.imageMap,"l ast");
dojo.event.connect(mapArea,"onmouseover",tour,"mou seOverArea");
dojo.event.connect(mapArea,"onmouseout",tour,"mous eOutArea");
}
}
},

when I resize the viewport, the map is supposed to be re-generated to take
account of the new image. If I look at the page's DOM using the Firefox
DOM inspector, it looks like this is happening correctly, but the browser
isn't using the new image map - the hotspots are still there, but in the
wrong place on the image, as if it's still using the old map (which should
have been deleted by when the viewport was resized)

The code that resizes the viewport and reloads the image is below:

resizeViewport: function(newsize) {
// resizes the viewport.
tour.panoDiv.style.height=newsize+"px";
tour.panoDiv.style.width=(newsize*tour.viewportRat io)+"px";
tour.panoDiv.style.clip="rect(0px,"+(newsize*tour. viewportRatio)+"px,"+newsize+"px,0px)";
tour.panoInnerDiv.style.height=newsize+"px";
tour.panoInnerDiv.style.width=(newsize*tour.viewpo rtRatio)+"px";
tour.panoInnerDiv.style.clip="rect(0px,"+(newsize* tour.viewportRatio)+"px,"+newsize+"px,0px)";
// resize the image if necessary.
if (newsize != tour.resolution) {
// image size has changed, so reload the image
tour.resolution=newsize;
tour.panoReady=0; // disable the panorama code while the image loads.
// load a new image. showPano will be called by an event once the image has loaded.
tour.panoImg=new tourImage(tour.panoImgPath+tour.panoImgPrefix+"-"+tour.resolution+".jpg");
// loads the image and sets a callback on tour.showPano
tour.panoImg.preload(tour.showPano);
//alert("return:"+tour.panoImg.name);
};
// create the image map.
tour.makeImageMap();
},
showPano: function() {
// shows the images in the panorama, once they have been loaded.
//alert("image has loaded. width:"+tour.panoImg.width+" height:"+tour.panoImg.height+" ratio:"+tour.panoImg.ratio+" name:"+tour.panoImg.name);
//alert("image loaded");
tour.setPanoImg(tour.panoImgTag1);
tour.setPanoImg(tour.panoImgTag2);
tour.panoImgTag1.usemap="#panoMap";
tour.panoImgTag2.usemap="#panoMap";
tour.moveImages();
tour.panoImgTag1.style.visibility="visible";
tour.panoImgTag2.style.visibility="visible";
tour.panoMsgSpan.style.visibility="hidden";
// enable the panorama scrolling code.
tour.panoReady=-1;
//alert("panorama ready");
},

The full code is at: http://lofty.dyndns.info/pano2/js/pano.js
The demo page is at: http://lofty.dyndns.info/pano2/pano-test.html

What I would like to know is whether this is a browser bug that anyone
else has come across, or if I'm doing something wrong in the way I've set
up the image map. As far as I can see, it's the former, because it works
OK when it first loads. If it is a bug, does anyone have any idea how to
trick the browser into using the correct map??

thanks,

andy

--
http://www.niftybits.ukfsn.org/

remove 'n-u-l-l' to email me. html mail or attachments will go in the spam
bin unless notified with [html] or [attachment] in the subject line.

May 31 '06 #1
3 2571
Andy Baxter said:

(reposted with some more code)
I have an image scrolling in a viewport for a panoramic image
viewer. The viewport can be resized to several set resolutions so people
can adjust the size according to their bandwidth. There are hotspots on
the image which have been defined using an image map. This map is
generated in javascript using the following code (in the object 'tour.'):

makeImageMap: function() {
// creates an HTML nodeset which is an imagemap for the current view.
//alert("making image map");
if (tour.imageMap!=0) {
// delete the old image map
tour.panoInnerDiv.removeChild(tour.imageMap);
}
tour.imageMap=document.createElement("map");
tour.imageMap.name="panoMap";
tour.imageMap.style.zIndex="3";
dojo.dom.insertAtPosition(tour.imageMap,tour.panoI nnerDiv,"first");
for (var i=0; i<tour.curView.links.length; i++) {
var link=tour.curView.links[i];
//alert("found link:"+link.id);
for (var j=0; j<link.areas.length; j++) {
//alert("found area");
var mapArea=document.createElement("area");
var area=link.areas[j]; // area is an array of point objects.
var pointStr="";
for (var k=0; k<area.length; k++) {
var point=area[k];
if (pointStr!="") { pointStr += ","; };
var mapX=tour.resolution*tour.panoImg.ratio*point.pan;
var mapY=tour.resolution*point.height;
pointStr+=mapX.toFixed(0)+","+mapY.toFixed(0);
// alert("adding point with pan:"+point.pan+",height:"+point.height);
}
mapArea.shape="poly";
mapArea.nohref="";
mapArea.coords=pointStr;
mapArea.style.cursor="hand";
//alert("pointStr:"+mapArea.coords);
mapArea.id=link.type+"--"+link.id+"--"+j;
//var id=tour.getAreaId(mapArea);
dojo.dom.insertAtPosition(mapArea,tour.imageMap,"l ast");
dojo.event.connect(mapArea,"onmouseover",tour,"mou seOverArea");
dojo.event.connect(mapArea,"onmouseout",tour,"mous eOutArea");
}
}
},

when I resize the viewport, the map is supposed to be re-generated to take
account of the new image. If I look at the page's DOM using the Firefox
DOM inspector, it looks like this is happening correctly, but the browser
isn't using the new image map - the hotspots are still there, but in the
wrong place on the image, as if it's still using the old map (which should
have been deleted by when the viewport was resized)

The code that resizes the viewport and reloads the image is below:

resizeViewport: function(newsize) {
// resizes the viewport.
tour.panoDiv.style.height=newsize+"px";
tour.panoDiv.style.width=(newsize*tour.viewportRat io)+"px";
tour.panoDiv.style.clip="rect(0px,"+(newsize*tour. viewportRatio)+"px,"+newsize+"px,0px)";
tour.panoInnerDiv.style.height=newsize+"px";
tour.panoInnerDiv.style.width=(newsize*tour.viewpo rtRatio)+"px";
tour.panoInnerDiv.style.clip="rect(0px,"+(newsize* tour.viewportRatio)+"px,"+newsize+"px,0px)";
// resize the image if necessary.
if (newsize != tour.resolution) {
// image size has changed, so reload the image
tour.resolution=newsize;
tour.panoReady=0; // disable the panorama code while the image loads.
// load a new image. showPano will be called by an event once the image has loaded.
tour.panoImg=new tourImage(tour.panoImgPath+tour.panoImgPrefix+"-"+tour.resolution+".jpg");
// loads the image and sets a callback on tour.showPano
tour.panoImg.preload(tour.showPano);
//alert("return:"+tour.panoImg.name);
};
// create the image map.
tour.makeImageMap();
},
showPano: function() {
// shows the images in the panorama, once they have been loaded.
//alert("image has loaded. width:"+tour.panoImg.width+" height:"+tour.panoImg.height+" ratio:"+tour.panoImg.ratio+" name:"+tour.panoImg.name);
//alert("image loaded");
tour.setPanoImg(tour.panoImgTag1);
tour.setPanoImg(tour.panoImgTag2);
tour.panoImgTag1.usemap="#panoMap";
tour.panoImgTag2.usemap="#panoMap";
tour.moveImages();
tour.panoImgTag1.style.visibility="visible";
tour.panoImgTag2.style.visibility="visible";
tour.panoMsgSpan.style.visibility="hidden";
// enable the panorama scrolling code.
tour.panoReady=-1;
//alert("panorama ready");
},
sorry - I forgot to paste this function:

setPanoImg: function(img) {
// set properties of an image element
img.src=tour.panoImg.name;
img.style.width=Math.floor(tour.resolution*tour.pa noImg.ratio)+"px";
img.style.height=tour.resolution+"px";
},
The full code is at: http://lofty.dyndns.info/pano2/js/pano.js
The demo page is at: http://lofty.dyndns.info/pano2/pano-test.html

What I would like to know is whether this is a browser bug that anyone
else has come across, or if I'm doing something wrong in the way I've set
up the image map. As far as I can see, it's the former, because it works
OK when it first loads. If it is a bug, does anyone have any idea how to
trick the browser into using the correct map??

thanks,

andy


--
http://www.niftybits.ukfsn.org/

remove 'n-u-l-l' to email me. html mail or attachments will go in the spam
bin unless notified with [html] or [attachment] in the subject line.

May 31 '06 #2
Andy Baxter said:
I have an image scrolling in a viewport for a panoramic image
viewer. The viewport can be resized to several set resolutions so people
can adjust the size according to their bandwidth. There are hotspots on
the image which have been defined using an image map. This map is
generated in javascript using the following code (in the object 'tour.'):

makeImageMap: function() {
// creates an HTML nodeset which is an imagemap for the current view.
//alert("making image map");
if (tour.imageMap!=0) {
// delete the old image map
tour.panoInnerDiv.removeChild(tour.imageMap);
}
tour.imageMap=document.createElement("map");
tour.imageMap.name="panoMap";
tour.imageMap.style.zIndex="3";
dojo.dom.insertAtPosition(tour.imageMap,tour.panoI nnerDiv,"first");
for (var i=0; i<tour.curView.links.length; i++) {
var link=tour.curView.links[i];
//alert("found link:"+link.id);
for (var j=0; j<link.areas.length; j++) {
//alert("found area");
var mapArea=document.createElement("area");
var area=link.areas[j]; // area is an array of point objects.
var pointStr="";
for (var k=0; k<area.length; k++) {
var point=area[k];
if (pointStr!="") { pointStr += ","; };
var mapX=tour.resolution*tour.panoImg.ratio*point.pan;
var mapY=tour.resolution*point.height;
pointStr+=mapX.toFixed(0)+","+mapY.toFixed(0);
// alert("adding point with pan:"+point.pan+",height:"+point.height);
}
mapArea.shape="poly";
mapArea.nohref="";
mapArea.coords=pointStr;
mapArea.style.cursor="hand";
//alert("pointStr:"+mapArea.coords);
mapArea.id=link.type+"--"+link.id+"--"+j;
//var id=tour.getAreaId(mapArea);
dojo.dom.insertAtPosition(mapArea,tour.imageMap,"l ast");
dojo.event.connect(mapArea,"onmouseover",tour,"mou seOverArea");
dojo.event.connect(mapArea,"onmouseout",tour,"mous eOutArea");
}
}
},

when I resize the viewport, the map is supposed to be re-generated to take
account of the new image. If I look at the page's DOM using the Firefox
DOM inspector, it looks like this is happening correctly, but the browser
isn't using the new image map - the hotspots are still there, but in the
wrong place on the image, as if it's still using the old map (which should
have been deleted by when the viewport was resized)

The code that resizes the viewport and reloads the image is below:

resizeViewport: function(newsize) {
// resizes the viewport.
tour.panoDiv.style.height=newsize+"px";
tour.panoDiv.style.width=(newsize*tour.viewportRat io)+"px";
tour.panoDiv.style.clip="rect(0px,"+(newsize*tour. viewportRatio)+"px,"+newsize+"px,0px)";
tour.panoInnerDiv.style.height=newsize+"px";
tour.panoInnerDiv.style.width=(newsize*tour.viewpo rtRatio)+"px";
tour.panoInnerDiv.style.clip="rect(0px,"+(newsize* tour.viewportRatio)+"px,"+newsize+"px,0px)";
// resize the image if necessary.
if (newsize != tour.resolution) {
// image size has changed, so reload the image
tour.resolution=newsize;
tour.panoReady=0; // disable the panorama code while the image loads.
// load a new image. showPano will be called by an event once the image has loaded.
tour.panoImg=new tourImage(tour.panoImgPath+tour.panoImgPrefix+"-"+tour.resolution+".jpg");
// loads the image and sets a callback on tour.showPano
tour.panoImg.preload(tour.showPano);
//alert("return:"+tour.panoImg.name);
};
// create the image map.
tour.makeImageMap();
},
showPano: function() {
// shows the images in the panorama, once they have been loaded.
//alert("image has loaded. width:"+tour.panoImg.width+" height:"+tour.panoImg.height+" ratio:"+tour.panoImg.ratio+" name:"+tour.panoImg.name);
//alert("image loaded");
tour.setPanoImg(tour.panoImgTag1);
tour.setPanoImg(tour.panoImgTag2);
tour.panoImgTag1.usemap="#panoMap";
tour.panoImgTag2.usemap="#panoMap";
tour.moveImages();
tour.panoImgTag1.style.visibility="visible";
tour.panoImgTag2.style.visibility="visible";
tour.panoMsgSpan.style.visibility="hidden";
// enable the panorama scrolling code.
tour.panoReady=-1;
//alert("panorama ready");
},

The full code is at: http://lofty.dyndns.info/pano2/js/pano.js
The demo page is at: http://lofty.dyndns.info/pano2/pano-test.html

What I would like to know is whether this is a browser bug that anyone
else has come across, or if I'm doing something wrong in the way I've set
up the image map. As far as I can see, it's the former, because it works
OK when it first loads. If it is a bug, does anyone have any idea how to
trick the browser into using the correct map??

thanks,

andy


update - I've tried taking the IMG tags out of the html altogether and
generating them using DOM calls. This works as far as the images are
concerned, but now it's not picking up the image map at all. If anyone has
any clue how to resolve this, I would appreciate it, as I'm starting to
run out of ideas (apart from writing my own image map code, which I
probably could do but would rather not ;) )

--
http://www.niftybits.ukfsn.org/

remove 'n-u-l-l' to email me. html mail or attachments will go in the spam
bin unless notified with [html] or [attachment] in the subject line.

May 31 '06 #3
Andy Baxter said:
I have an image scrolling in a viewport for a panoramic image
viewer. The viewport can be resized to several set resolutions so people
can adjust the size according to their bandwidth. There are hotspots on
the image which have been defined using an image map. This map is
generated in javascript using the following code (in the object 'tour.'):

makeImageMap: function() {
// creates an HTML nodeset which is an imagemap for the current view.
//alert("making image map");
if (tour.imageMap!=0) {
// delete the old image map
tour.panoInnerDiv.removeChild(tour.imageMap);
}
tour.imageMap=document.createElement("map");
tour.imageMap.name="panoMap";
tour.imageMap.style.zIndex="3";
dojo.dom.insertAtPosition(tour.imageMap,tour.panoI nnerDiv,"first");
for (var i=0; i<tour.curView.links.length; i++) {
var link=tour.curView.links[i];
//alert("found link:"+link.id);
for (var j=0; j<link.areas.length; j++) {
//alert("found area");
var mapArea=document.createElement("area");
var area=link.areas[j]; // area is an array of point objects.
var pointStr="";
for (var k=0; k<area.length; k++) {
var point=area[k];
if (pointStr!="") { pointStr += ","; };
var mapX=tour.resolution*tour.panoImg.ratio*point.pan;
var mapY=tour.resolution*point.height;
pointStr+=mapX.toFixed(0)+","+mapY.toFixed(0);
// alert("adding point with pan:"+point.pan+",height:"+point.height);
}
mapArea.shape="poly";
mapArea.nohref="";
mapArea.coords=pointStr;
mapArea.style.cursor="hand";
//alert("pointStr:"+mapArea.coords);
mapArea.id=link.type+"--"+link.id+"--"+j;
//var id=tour.getAreaId(mapArea);
dojo.dom.insertAtPosition(mapArea,tour.imageMap,"l ast");
dojo.event.connect(mapArea,"onmouseover",tour,"mou seOverArea");
dojo.event.connect(mapArea,"onmouseout",tour,"mous eOutArea");
}
}
},

when I resize the viewport, the map is supposed to be re-generated to take
account of the new image. If I look at the page's DOM using the Firefox
DOM inspector, it looks like this is happening correctly, but the browser
isn't using the new image map - the hotspots are still there, but in the
wrong place on the image, as if it's still using the old map (which should
have been deleted by when the viewport was resized)

The code that resizes the viewport and reloads the image is below:

resizeViewport: function(newsize) {
// resizes the viewport.
tour.panoDiv.style.height=newsize+"px";
tour.panoDiv.style.width=(newsize*tour.viewportRat io)+"px";
tour.panoDiv.style.clip="rect(0px,"+(newsize*tour. viewportRatio)+"px,"+newsize+"px,0px)";
tour.panoInnerDiv.style.height=newsize+"px";
tour.panoInnerDiv.style.width=(newsize*tour.viewpo rtRatio)+"px";
tour.panoInnerDiv.style.clip="rect(0px,"+(newsize* tour.viewportRatio)+"px,"+newsize+"px,0px)";
// resize the image if necessary.
if (newsize != tour.resolution) {
// image size has changed, so reload the image
tour.resolution=newsize;
tour.panoReady=0; // disable the panorama code while the image loads.
// load a new image. showPano will be called by an event once the image has loaded.
tour.panoImg=new tourImage(tour.panoImgPath+tour.panoImgPrefix+"-"+tour.resolution+".jpg");
// loads the image and sets a callback on tour.showPano
tour.panoImg.preload(tour.showPano);
//alert("return:"+tour.panoImg.name);
};
// create the image map.
tour.makeImageMap();
},
showPano: function() {
// shows the images in the panorama, once they have been loaded.
//alert("image has loaded. width:"+tour.panoImg.width+" height:"+tour.panoImg.height+" ratio:"+tour.panoImg.ratio+" name:"+tour.panoImg.name);
//alert("image loaded");
tour.setPanoImg(tour.panoImgTag1);
tour.setPanoImg(tour.panoImgTag2);
tour.panoImgTag1.usemap="#panoMap";
tour.panoImgTag2.usemap="#panoMap";
tour.moveImages();
tour.panoImgTag1.style.visibility="visible";
tour.panoImgTag2.style.visibility="visible";
tour.panoMsgSpan.style.visibility="hidden";
// enable the panorama scrolling code.
tour.panoReady=-1;
//alert("panorama ready");
},

The full code is at: http://lofty.dyndns.info/pano2/js/pano.js
The demo page is at: http://lofty.dyndns.info/pano2/pano-test.html

What I would like to know is whether this is a browser bug that anyone
else has come across, or if I'm doing something wrong in the way I've set
up the image map. As far as I can see, it's the former, because it works
OK when it first loads. If it is a bug, does anyone have any idea how to
trick the browser into using the correct map??


I've now got this working - putting the image tags in using DOM calls does
fix the original bug in FF (I still think there is one), but there was a
problem with the code I'd written to do this.

--
http://www.niftybits.ukfsn.org/

remove 'n-u-l-l' to email me. html mail or attachments will go in the spam
bin unless notified with [html] or [attachment] in the subject line.

Jun 1 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ohaya | last post by:
Hi, We've been having a problem with one particular page that has a button on it, and a "tall" image (top-to-bottom). The button calls some simple Javascript to print the frame in which the...
3
by: CanyonJ | last post by:
I've been running into a frustrating problem for a while now. I use image.FromStream to open a tif, then perform some drawstring methods, and then save the file again. The tiffs are in 1 bit per...
15
by: Anand Ganesh | last post by:
HI All, I have an Image. I want to clip a portion of it and copy to another image. How to do this? I know the bounding rectangle to clip. Any suggestions please. Thanks for your time and...
3
by: Sandi | last post by:
I have a simple problem: I have an Access database (images.mdb) that has 2 columns: one is the id if the picture (an integer) and one (column named picture) is a field of type OLE Object which...
2
by: Andreas Viklund via DotNetMonster.com | last post by:
Hi! I am developing an application in ASP.NET that takes an image, that have been created with a digital camera or camera phone, and processes it, to get data from it. The image taken by the user...
7
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard...
5
by: Ricardo Furtado | last post by:
I'm trying, for a week or two, to create a procedure in order to rotate the image in any picturebox control in a cephalometry software. I've found a web site that shows how that can be done:...
23
by: Peter | last post by:
I have a problem with a page show_image.asp that returns a jpg image under Windows XP Pro SP2. The page sets content type as: Response.ContentType = "image/jpg" While this works perfectly fine...
3
by: kayahr | last post by:
Hi there, I have a strange problem in Internet Explorer (IE6 and IE7). I'm writing a JavaScript application which allows the user to edit a photo composition. So when the user selects a photo then...
2
by: studentofknowledge | last post by:
For some unknown reason ie is placing images I have in a div in a weird way. One image is overlapping another but this problem is not occuring in mozilla. I have looked at my code over and over again...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.