Weather map
<h2>Composite map markers</h2> This demo showcases how you can combine several elements into a single map marker. In this case we combine an animated SVG image and a text label. They are placed at certain coordinates and therefore move with map.
by Rohit Bisht
HTML
<script src="https://www.amcharts.com/lib/4/core.js"></script>
<script src="https://www.amcharts.com/lib/4/maps.js"></script>
<script src="https://www.amcharts.com/lib/4/geodata/worldHigh.js"></script>
<script src="https://www.amcharts.com/lib/4/themes/animated.js"></script>
<div id="chartdiv"></div>
CSS
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}
#chartdiv {
width: 100%;
height: 500px;
}
JavaScript
/**
* ---------------------------------------
* This demo was created using amCharts 4.
*
* For more information visit:
* https://www.amcharts.com/
*
* Documentation is available at:
* https://www.amcharts.com/docs/v4/
* ---------------------------------------
*/
// Themes begin
am4core.useTheme(am4themes_animated);
// Themes end
// Create map instance
var chart = am4core.create("chartdiv", am4maps.MapChart);
// Set map definition
chart.geodata = am4geodata_worldHigh;
// Set projection
chart.projection = new am4maps.projections.Miller();
// Center on the groups by default
chart.homeZoomLevel = 6;
chart.homeGeoPoint = { longitude: 10, latitude: 52 };
// Polygon series
var polygonSeries = chart.series.push(new am4maps.MapPolygonSeries());
polygonSeries.useGeodata = true;
// Image series
var imageSeries = chart.series.push(new am4maps.MapImageSeries());
var imageTemplate = imageSeries.mapImages.template;
imageTemplate.propertyFields.longitude = "longitude";
imageTemplate.propertyFields.latitude = "latitude";
imageTemplate.nonScaling = true;
/* imageTemplate.propertyFields.label.hidden = "true"; */
//imageTemplate.propertyFields.label = "{label}";
var image = imageTemplate.createChild(am4core.Image);
image.propertyFields.href = "imageURL";
image.width = 50;
image.height = 50;
image.horizontalCenter = "middle";
image.verticalCenter = "middle";
imageSeries.data = [{
"latitude": 40.416775,
"longitude": -3.703790,
"imageURL": "https://www.amcharts.com/lib/images/weather/animated/rainy-1.svg",
"width": 32,
"height": 32,
"label": "Madrid: +22C"
}, {
"latitude": 48.856614,
"longitude": 2.352222,
"imageURL": "https://www.amcharts.com/lib/images/weather/animated/thunder.svg",
"width": 32,
"height": 32,
"label": "Paris: +18C"
}, {
"latitude": 52.520007,
"longitude": 13.404954,
"imageURL": "https://www.amcharts.com/lib/images/weather/animated/cloudy-day-1.svg",
"width": 32,
"height": 32,
"label": "Berlin: +13C"
}, {
...