Reputation: 163
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.com/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?
Upvotes: 3
Views: 5702
Reputation: 1
My solution :
http://kirmizikaya.net/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(); }); ... ......
Upvotes: 0
Reputation: 391
According to their tips page http://www.amcharts.com/tips/auto-zoom-country-map-loads/ the easiest solution IMO is to set linkToObject
in dataProvider
:
"dataProvider": {
"map": "worldLow",
"getAreasFromMap": true,
"linkToObject": "US"
},
Upvotes: 2
Reputation: 651
Alternative solution:
map.zoomToGroup([map.getObjectById('RO')]);
The map will start with the selected region zoomed in.
Upvotes: 1
Reputation: 150
map.addListener("clickMapObject", function (event) {
if (event.mapObject.id == "FR") {
loadNewMap("http://www.ammap.com/lib/maps/js/franceLow.js", "franceLow");
}
I think this will help
Upvotes: 1
Reputation: 46
I 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).
Upvotes: 3