I am aware there is a post with a similar title but I am not trying to achieve the same thing. I am trying to achieve something similar to what this website is doing - https://www.commuterclub.co.uk/
(scroll down to the section where is says "Helping commuters across the UK get a better commute")
I am getting information from a JSON api providing me with X and Y coordinates and some text, I want to populate an image with a circle (respresent the x & y coordinates) and a bubble with the text using javascript like in the commuter club website.
I found a plugin - http://www.jqueryscript.net/zoom/jQuery-Plugin-For-Adding-Notes-Markers-To-An-Image-imgNotes.html - and i was able to plot the image with markers and a tooltip but not what i am trying to achieve.
EDIT
I have used the above plugin to put the markers on my image and make them disappear and reappear randomly. see code below:
<script type="text/javascript">
;(function($) {
$(document).ready(function() {
var $img = $("#image").imgNotes({
onShow: $.noop,
onAdd: function() {
this.options.vAll = "bottom";
this.options.hAll = "middle";
var elem = $(document.createElement('div')).addClass("mrkr").css({
"background-color": "#9AB54D",
height: "8px",
width: "8px",
"border-radius": "60px",
"text-align": "center",
color: "#fff"
}).attr("title", "");
var self = this;
$(elem).tooltip({
content: function() {
return $(elem).data("note");
}
});
return elem;
}
});
$(".mrkr").tooltip().tooltip("open");
$img.imgNotes("import", [ {x: "0.5", y:"0.5", note:"Text 1"},
{x: "0.322", y:"0.269", note: "Text 2"},
{x: "0.9", y:"0.6", note: "Text 3"},
{x: "0.1", y:"0.456", note: "Text 4"},
{x: "0.345", y:"0.987", note: "Text 5"},
{x: "0.824", y: "0.593", note: "Text 6"}]);
var divs = $('.viewport').find('.mrkr'),
len = divs.length,
randomDiv,
speed = 2000;
var interval = setInterval(
function() {
randomDiv = Math.floor(Math.random()*len);
divs.removeClass('show');
divs.eq(randomDiv).addClass('show');
} , speed);
});
})(jQuery);
</script>
I want to show all 4 markers at a given time and as a new one appears one of the older one fades out.
Javascript isn't my strongest language so all the help you can give will be appreciated.
Thanks