Image Map Border on Hover - hover

I'm hoping to have a hover effect, preferably a border color or glow around the poly area on this image map. Below is my Javascript:
<script>
window.onload = function () {
var ImageMap = function (map, img) {
var n,
areas = map.getElementsByTagName('area'),
len = areas.length,
coords = [],
previousWidth = 700;
for (n = 0; n < len; n++) {
coords[n] = areas[n].coords.split(',');
}
this.resize = function () {
var n, m, clen,
x = img.offsetWidth / previousWidth;
for (n = 0; n < len; n++) {
clen = coords[n].length;
for (m = 0; m < clen; m++) {
coords[n][m] *= x;
}
areas[n].coords = coords[n].join(',');
}
previousWidth = img.offsetWidth;
return true;
};
window.onresize = this.resize;
},
imageMap = new ImageMap(document.getElementById('map_ID'), document.getElementById('img_ID'));
imageMap.resize();
return;
}
</script>
And the HTML that includes the coordinates for the sections that I would like highlighted on hover:
<div style="width:100%;">
<img id="img_ID" src="http://libraries.adelphi.edu/files/2016/10/Overview-Final.jpg" usemap="#map" border="0" width="100%" alt="" />
</div>
<map id="map_ID" name="map">
<area shape="poly" coords="133,309,70,330,68,347,199,392,239,373,193,364,191,342,209,340,209,329" alt="Level S" title="Level S" href="http://libraries.adelphi.edu/files/2016/10/Swirbul-Level-S-10-2016.jpg" target="_self" />
<area shape="poly" coords="244,310,200,324,64,286,64,267,146,243,207,257,208,294,241,293" alt="Level 2S" title="Level 2S" href="http://libraries.adelphi.edu/files/2016/10/Swirbul-Level-2S-10-2016.jpg" target="_self" />
<area shape="poly" coords="193,344,194,356,350,406,469,343,469,328,319,295,294,319,253,343,236,341" alt="Level C" title="Level C" href="http://libraries.adelphi.edu/files/2016/10/Swirbul-Level-C-10-2016.jpg" target="_self" />
<area shape="poly" coords="188,236,188,252,350,287,673,162,674,153,500,136,355,174,291,167,291,221,240,241,218,236" alt="1st Floor" title="1st Floor" href="http://libraries.adelphi.edu/files/2016/10/Swirbul-Floor1-10-2016.jpg" target="_self" />
<area shape="poly" coords="187,233,186,250,60,221,61,208,165,180,204,184,207,226,205,232" alt="Level 3S" title="Level 3S" href="http://libraries.adelphi.edu/files/2016/10/Swirbul-Level-3S-10-2016.jpg" target="_self" />
<area shape="poly" coords="237,171,190,180,54,156,56,142,166,116,202,120,204,128,182,127,182,149,205,151,233,158" alt="Level 4S" title="Level 4S" href="http://libraries.adelphi.edu/files/2016/10/Swirbul-Level-4S-10-2016.jpg" target="_self" />
<area shape="poly" coords="184,129,184,147,350,172,679,88,680,77,433,58,291,78,291,119,213,131" alt="2nd Floor" title="2nd Floor" href="http://libraries.adelphi.edu/files/2016/10/Swirbul-Floor2-10-2016.jpg" target="_self" />
<area shape="poly" coords="235,98,188,104,51,88,51,74,166,51,201,54,201,80,236,83" alt="Level 5S" title="Level 5S" href="http://libraries.adelphi.edu/files/2016/10/Swirbul-Level-5S-10-2016.jpg" target="_self" />
</map>
Is there a Javascript or CSS solution?
This is a rough example of what I'm trying to achieve:
http://www.outsharked.com/imagemapster/default.aspx?demos.html

you are try to "onMouseOver" and "onMouseOut".
example
<map id="map_ID" name="map">
<area shape="poly" coords="133,309,70,330,68,347,199,392,239,373,193,364,191,342,209,340,209,329" alt="Level S" title="Level S" href="http://libraries.adelphi.edu/files/2016/10/Swirbul-Level-S-10-2016.jpg" target="_self"
onMouseOver="if(document.images) document.getElementById('map_ID').src= ' Over Image URL';"
onMouseOut="if(document.images) document.getElementById('map_ID').src= 'Out Image URL';"
/>

Related

Not able to get all polygons on Interactive Image Map in Js

I'm using an Image of all counties in Texas on webpage using
<img src="https://txbbw.ml/static/images/jibh.png" width="100%" usemap="#image-map">
<map name="image-map">
<area target="" alt="Caldwell" title="Caldwell" href="https://txbbw.ml/map/Caldwell/-96.7177005/30.5307282" shape="poly" coords="2146, 2860, 2552, 3200, 2942, 2990, 2483, 2599"/>
<area target="" alt="Gonzales" title="Gonzales" href="https://txbbw.ml/map/Gonzales/-97.4772359/29.5048146" shape="poly" coords="2946, 2997, 2556, 3213, 2503, 3183, 2202, 3590, 2535, 3920, 3046, 3538, 3098, 3374, 3095, 3262, 3193, 3186" />
<area target="" alt="Karnes" title="Karnes" href="https://txbbw.ml/map/Karnes/-97.915897/28.8880769" shape="poly" coords="2538, 3915, 2337, 4068, 2585, 4327, 2312, 4525, 2291, 4510, 2217, 4506, 2113, 4449, 1992, 4495, 1752, 4231, 2379, 3771" />
<area target="" alt="Bee" title="Bee" href="https://txbbw.ml/map/Bee/-97.7862049/28.409946" shape="poly" coords="2118, 4466, 2217, 4528, 2309, 4538, 2410, 4702, 2466, 4754, 2593, 4745, 2615, 4831, 2700, 4878, 2710, 4866, 2847, 4928, 2600, 5260, 2271, 5196, 1885, 4536" />
<area target="" alt="SAN PATRICIO" title="SAN PATRICIO" href="https://txbbw.ml/map/SAN PATRICIO/-97.7745336/27.9576203" shape="poly" coords="2257, 5207, 2149, 5294, 2193, 5382, 2304, 5394, 2278, 5508, 2622, 5612, 2874, 5606, 3098, 5670, 3177, 5576, 3002, 5336, 2875, 5282, 2719, 5235, 2601, 5282" />
<area target="" alt="Nueces" title="Nueces" href="https://txbbw.ml/map/Nueces/-97.6620641/27.7887978" shape="poly" coords="2239, 5500, 2105, 5612, 2099, 5937, 2184, 5973, 2236, 6049, 2927, 6051, 3033, 5881, 2879, 5841, 2838, 5715, 2521, 5645" />
<area target="" alt="Kleberg" title="Kleberg" href="https://txbbw.ml/map/Kleberg/-97.8969139/27.5028167" shape="poly" coords="2219, 6064, 2091, 5962, 1925, 5956, 1932, 6457, 2045, 6527, 2815, 6371, 2930, 6058" />
<area target="" alt="Refugio" title="Refugio" href="https://txbbw.ml/map/Refugio/-97.2935169/28.3080144" shape="poly" coords="2650, 5214, 2874, 4919, 3166, 4693, 3315, 4720, 3492, 4794, 3532, 4779, 3680, 4876, 3657, 4998, 3192, 5090, 3314, 5190, 3053, 5336, 2858, 5233" />
<area target="" alt="Galveston" title="Galveston" href="https://txbbw.ml/map/Galveston/-94.9566483/29.393116" shape="poly" coords="6105, 3851, 5825, 3435, 5843, 3315, 5914, 3397, 6103, 3320, 6386, 3230, 6403, 3358, 6642, 3385, 6977, 3269, 6999, 3335, 6534, 3509, 6512, 3641" />
<area target="" alt="Harris" title="Harris" href="https://txbbw.ml/map/Harris/-95.3760728/29.762121" shape="poly" coords="5946, 3366, 6217, 3076, 6228, 2940, 6112, 2829, 6094, 2733, 5999, 2475, 5784, 2663, 5696, 2676, 5471, 2562, 5374, 2484, 5069, 2601, 4826, 2491, 5004, 2981, 5553, 3265, 5762, 3231" />
<area target="" alt="Sabine" title="Sabine" href="https://txbbw.ml/map/Sabine/-93.8547083/31.343520" shape="poly" coords="7457, 1131, 7636, 1099, 8064, 1069, 7812, 452, 7398, 552" />
<area target="" alt="Newton" title="Newton" href="https://txbbw.ml/map/Newton/-93.7616915/30.8510301" shape="poly" coords="7637, 1107, 8061, 1077, 8181, 1295, 8049, 1778, 7893, 1941, 7877, 2226, 7919, 2353, 7648, 2361, 7702, 1390" />
<area target="" alt="Jasper" title="Jasper" href="https://txbbw.ml/map/Jasper/-94.0266033/30.9249516" shape="poly" coords="7636, 1106, 6885, 1241, 6895, 1315, 7157, 1263, 7295, 1587, 7353, 1739, 7448, 1815, 7391, 1903, 7361, 2133, 7357, 2360, 7646, 2358, 7696, 1395" />
<area target="" alt="Orange" title="Orange" href="https://txbbw.ml/map/Orange/-93.7478422/30.0918584" shape="poly" coords="7351, 2364, 7384, 2423, 7355, 2477, 7412, 2523, 7387, 2588, 7473, 2618, 7472, 2649, 7742, 2745, 7976, 2549, 7939, 2364" />
<area target="" alt="Jefferson" title="Jefferson" href="https://txbbw.ml/map/Jefferson/-94.3525849/32.7622043" shape="poly" coords="7027, 3221, 7023, 2850, 6904, 2852, 6902, 2543, 7064, 2548, 7137, 2508, 7137, 2464, 7271, 2447, 7345, 2471, 7404, 2534, 7386, 2579, 7481, 2655, 7711, 2736, 7490, 2984, 7298, 3117" />
</map>
I'm able to click on few counties such as Harris, Bee ,etc. but not on other, what might be wrong here?
I'm using https://summerstyle.github.io/summer/ to create polygons

I am trying to map an image so it will link certain sections to a different page I need another set of eyes

I can't get links onto certain parts of the image I am using. Even though I looked over it numerous times. Can someone else have a look to see if my code is off.
<img id="gtxports" alt="GTX Titan Black Ports"
src="https://i.ibb.co/h9y4V3S/gtxtitanports.jpg" usemap="gtxpports">
<map name="gtxpports" id="gtxPortsMap">
<area alt="Dual DVI D" title="Dual DVI D" href="dualdviD.html"
shape="rect" coords="1045, 453, 1653, 633" />
<area alt="Dual DVI I" title="Dual DVI I" href="dualdvii.html"
shape="rect" coords="1045, 773, 1653, 969" />
<area alt="HDMI Port" title="HDMI Port" href="hdmi.html" shape="rect"
coords="577, 829, 861, 965" />
<area alt="DisplayPort" title="DisplayPort" href="displayport.html"
shape="rect" coords="193, 825, 525, 969" />
</map>
Not sure where and how you are referring to the html link as I believe it's on your local machine. Rewriting the existing code works fine for me, refer below:
<img id="gtxports" alt="GTX Titan Black Ports"
src="https://i.ibb.co/h9y4V3S/gtxtitanports.jpg" usemap="gtxpports">
<map name="gtxpports" id="gtxPortsMap">
<area href="https://google.com" alt="Dual DVI D" title="Dual DVI D" target="_blank" shape="rect" coords="1045, 453, 1653, 633" />
<area href="https://google.com" alt="Dual DVI I" title="Dual DVI I" target="_blank" shape="rect" coords="1045, 773, 1653, 969" />
<area href="https://google.com" alt="HDMI Port" title="HDMI Port" target="_blank" shape="rect" coords="577, 829, 861, 965" />
<area href="https://google.com" alt="DisplayPort" title="DisplayPort" target="_blank" shape="rect" coords="193, 825, 525, 969" />
</map>
You can test this on real-time via https://htmledit.squarefree.com/ or any other real-time html viewer. Replace google.com with your link to see if it works, if it dosesn't then possibly some problem with the destination of the html pages you are referring to.

create hyperlink on part of image

I have a background image in my footer that has a number of different images inside it. I want to create links to the respective websites of each of the images using html or css but I don't know how. I was told that it can be done in this way though. Is this possible, or am i going to need to split the image into multiple ones?
You can use the HTML Map tag
An example would be:
<img src="GJ7SG.png" alt="" usemap="#map" />
<map name="map">
<area shape="rect" coords="788, 2, 867, 37" alt="Sun" href="someurl.htm"/>
<area shape="rect" coords="608, 1, 719, 37" alt="Sun" href="anotherurl.htm" />
<area shape="rect" coords="374, 0, 501, 39" />
<area shape="rect" coords="168, 0, 312, 38" />
<area shape="rect" coords="1, 7, 87, 39" />
</map>
You will have to do some playing around to get it how you want but that should get you started.
Add the href to each rectangle. You can generate the map here:
https://developer.cdn.mozilla.net/media/uploads/demos/s/u/summerstyle/365ccfd644f2b008c33f0046d2ba1a8f/summer-html-image-ma_1355318513_demo_package/index.html
Try using a HTML Image Map:
<img src="img" usemap="#mymap" />
<map name="mymap">
<area shape="rect" coords="0,0,200,300" href="linkurl" title="sometitle" alt="Hovertext" />
...
</map>
You maybe have to add the image to the foreground for it to work

Load random image from XML file

I have almost non-existanl knowledge on AS3/Flash CS5.
I need to load a random image from an XML file with the list of urls.
Every time I load the movie, it should load a random image.
Any idea how to do this?
I'm assuming this is what your xml file looks like:
<images>
<image url="http://url_to_image/1.png" width="100" height="100" />
<image url="http://url_to_image/2.png" width="100" height="100" />
<image url="http://url_to_image/3.png" width="100" height="100" />
<image url="http://url_to_image/4.png" width="100" height="100" />
<image url="http://url_to_image/5.png" width="100" height="100" />
</images>
And here's what you'll do to get a random one from those:
private function randomImage(imagesXML:XML):Object {
var imageList:XMLList=imagesXML.image;
var imageCollection:XMLListCollection=new XMLListCollection(imageList);
var random:int=Math.floor(Math.random() * imageCollection.length);
var r:Object={};
r.url=xmlCollection[random].#url;
r.width=Number(xmlCollection[random].#width);
r.height=Number(xmlCollection[random].#height);
return r;
}
And here's how you would call it:
private var x:XML=<images>
<image url="http://url_to_image/1.png" width="100" height="100" />
<image url="http://url_to_image/2.png" width="100" height="100" />
<image url="http://url_to_image/3.png" width="100" height="100" />
<image url="http://url_to_image/4.png" width="100" height="100" />
<image url="http://url_to_image/5.png" width="100" height="100" />
</images>;
var img:Object=randomImage(x);
Now you have img.url, img.width, img.height

Sort order file when sent to xml

I have the following statement:
$query = "SELECT * FROM aprstrack WHERE callsignSSID = 'VE9SC-9' order by reporttime desc limit 30 ";
It works but I am feeding the results to a xml file that needs the order reversed to what is displayed.
The display looks like this:
<?xml version="1.0" ?>
- <markers>
<marker call="VE9SC-9" lat="46.1088" lng="-64.8708" datetime="2012-01-20 20:26:33" course="" Speed="28" alt="" Icon="/P" />
<marker call="VE9SC-9" lat="46.1038" lng="-64.8633" datetime="2012-01-20 20:25:23" course="" Speed="26" alt="" Icon="/P" />
<marker call="VE9SC-9" lat="46.1038" lng="-64.8625" datetime="2012-01-20 20:25:19" course="" Speed="16" alt="" Icon="/P" />
<marker call="VE9SC-9" lat="46.1037" lng="-64.862" datetime="2012-01-20 20:25:11" course="" Speed="10" alt="" Icon="/P" />
<marker call="VE9SC-9" lat="46.1035" lng="-64.8622" datetime="2012-01-20 20:25:05" course="" Speed="14" alt="" Icon="/P" />
<marker call="VE9SC-9" lat="46.0978" lng="-64.86" datetime="2012-01-20 20:24:18" course="" Speed="18" alt="" Icon="/P" />
<marker call="VE9SC-9" lat="46.0943" lng="-64.8407" datetime="2012-01-20 20:21:40" course="" Speed="40" alt="" Icon="/P" />
<marker call="VE9SC-9" lat="46.0977" lng="-64.8178" datetime="2012-01-20 20:19:08" course="" Speed="12" alt="" Icon="/P" />
</markers>
The newest being listed on the top, what I need is the oldest listed on the top.
I have tried desc & ASC but that will not work what needs to be done ? I have looked on-line and I can not find an answer.
Thanks
Stephen
MySQL does the ordering first and then limits the results. That is why you would get the 30 oldest results. You need to do a subquery such that ordering happens after you have pulled the 30 newest records:
$query = "SELECT * FROM (SELECT * FROM aprstrack WHERE callsignSSID = 'VE9SC-9' order by reporttime desc limit 30) ORDER BY reporttime ASC";