admin管理员组文章数量:1353618
I’m working with the latest javascript version of ammap and I’m trying to get the correct country to load when a page is loading. I’m aware of the fact you can load the correct country by simply load the correct country js file
<script src="/js/ammap/maps/js/australiaLow.js"></script>
and then set the dataprovider correctly
var dataProvider = {
mapVar: AmCharts.maps.australiaLow,
getAreasFromMap: true
};
But my goal is to start with continentsLow and to drill down to the correct country by using javascript and no interaction of the user. This because the users should be able to navigate at all levels and the maps should load accordingly.
<script src="/js/ammap/maps/js/australiaLow.js"></script>
It’s similar to this example page, but in this example. But in this example you have to click before you will get to see the correct country. / I tried to load the map and set it and then reload the ammap but without success.
map.selectObject(map.getObjectById("AU"));
Any idea how to do this?
I’m working with the latest javascript version of ammap and I’m trying to get the correct country to load when a page is loading. I’m aware of the fact you can load the correct country by simply load the correct country js file
<script src="/js/ammap/maps/js/australiaLow.js"></script>
and then set the dataprovider correctly
var dataProvider = {
mapVar: AmCharts.maps.australiaLow,
getAreasFromMap: true
};
But my goal is to start with continentsLow and to drill down to the correct country by using javascript and no interaction of the user. This because the users should be able to navigate at all levels and the maps should load accordingly.
<script src="/js/ammap/maps/js/australiaLow.js"></script>
It’s similar to this example page, but in this example. But in this example you have to click before you will get to see the correct country. http://www.ammap./javascript-maps/zooming-to-countries-map/ I tried to load the map and set it and then reload the ammap but without success.
map.selectObject(map.getObjectById("AU"));
Any idea how to do this?
Share Improve this question edited Jun 20, 2013 at 13:14 Dan O 6,0902 gold badges34 silver badges52 bronze badges asked Jun 20, 2013 at 13:10 user1923728user1923728 1632 silver badges14 bronze badges5 Answers
Reset to default 3I had the same need and what I ended up doing is using the clickMapObject method to simulate a click on the map object I wanted it to start out with:
var mapObject = map.getObjectById('US');
map.clickMapObject(mapObject);
When I load the page it will zoom right into the country I selected (US).
According to their tips page http://www.amcharts./tips/auto-zoom-country-map-loads/ the easiest solution IMO is to set linkToObject
in dataProvider
:
"dataProvider": {
"map": "worldLow",
"getAreasFromMap": true,
"linkToObject": "US"
},
map.addListener("clickMapObject", function (event) {
if (event.mapObject.id == "FR") {
loadNewMap("http://www.ammap./lib/maps/js/franceLow.js", "franceLow");
}
jsfiddle demo
I think this will help
Alternative solution:
map.zoomToGroup([map.getObjectById('RO')]);
The map will start with the selected region zoomed in.
My solution :
http://kirmizikaya/blog/ammap-dynamically-load-map-of-the-country-on-click/
.. ..... $.getScript(filename, function (data, textStatus, jqxhr) {}) .done(function (script, textStatus) { var dataProvider = { mapVar: eval(mapVar), getAreasFromMap: true, }; // ilgili ülkenin haritasını bağlayalım map.dataProvider = dataProvider; //harita yüklensin map.validateData(); }); ... ......
本文标签: javascriptSet and zoom country map dynamically in AMMAPStack Overflow
版权声明:本文标题:javascript - Set and zoom country map dynamically in AMMAP - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743930465a2563746.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论