var map = AmCharts.makeChart( "mapChart", {
"type": "map",
"projection": "winkel3",
"theme": "none",
"imagesSettings": {
// "rollOverColor": "#089282",
// "rollOverScale": 3,
// "selectedScale": 3,
// "selectedColor": "#089282",
// "color": "#13564e"
},
"areasSettings": {
"unlistedAreasColor": "#666",
"outlineThickness": 0.1
},
"dataProvider": {
"map": "worldLow",
// "getAreasFromMap": true,
"images": [ {
"zoomLevel": 5,
"scale": 0.5,
"title": "Canada",
"latitude": -6.1670,
"longitude": 35.7497
}, {
"zoomLevel": 5,
"scale": 0.5,
"title": "Canada",
"latitude": 6.1228,
"longitude": 1.2255
}, {
"zoomLevel": 5,
"scale": 0.5,
"title": "Tunis",
"latitude": 36.8117,
"longitude": 10.1761
} ]
},
"export": {
"enabled": false
}
} );
// add events to recalculate map position when the map is moved or zoomed
map.addListener("positionChanged", updateCustomMarkers);
// this function will take current images on the map and create HTML elements for them
function updateCustomMarkers (event) {
// get map object
var map = event.chart;
// go through all of the images
for( var x in map.dataProvider.images) {
// get MapImage object
var image = map.dataProvider.images[x];
console.log(image)
// check if it has corresponding HTML element
if ('undefined' == typeof image.externalElement){
image.externalElement = createCustomMarker(image);
}
// reposition the element accoridng to coordinates
image.externalElement.style.top = map.latitudeToY(image.latitude) + 'px';
image.externalElement.style.left = map.longitudeToX(image.longitude) + 'px';
}
}
// this function creates and returns a new marker element
function createCustomMarker(image) {
// create holder
var holder =...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.