view raw
user1923728 user1923728 - 8 months ago 105
Javascript Question

Set and zoom country map dynamically in AMMAP

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.


Any idea how to do this?


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');

When I load the page it will zoom right into the country I selected (US).