本次演示提供了一个通过KineticJS空国家使用个SVG路径资源实现一个世界地图指示的小案例。当你的鼠标悬浮在某个国家的时候,演示会自动标示出来。
body { margin: 0px; padding: 0px; } #tango { position: absolute; top: 10px; left: 10px; padding: 10px; } #container { background-image: url('http://www.html5canvastutorials.com/demos/assets/map-background.png'); display: inline-block; overflow: hidden; height: 262px; width: 580px; background-position: 1px 1px; } var stage = new Kinetic.Stage({ container: 'container', width: 578, height: 260 }); var mapLayer = new Kinetic.Layer({ y: 20, scale: 0.6 }); /* * loop through country data stroed in the worldMap * variable defined in the worldMap.js asset */ for(var key in worldMap.shapes) { var path = new Kinetic.Path({ data: worldMap.shapes[key], fill: '#eee', stroke: '#555', strokeWidth: 1 }); path.on('mouseover', function() { this.setFill('red'); mapLayer.drawScene(); }); path.on('mouseout', function() { this.setFill('#eee'); mapLayer.drawScene(); }); mapLayer.add(path); } stage.add(mapLayer);
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号