Question

I'm writing a program with AmMaps where I want a user to click on a map of a country, and to be able to select and save locations.

I'm stuck on getting data back after the user clicks on the map. I used the "clickMapObject" event on another page, but in this case they aren't clicking anything.

  <script>
  var map;
  $(document).ready(function () {

    map = new AmCharts.AmMap();

    map.pathToImages = "ammap/images/";

    var dataProvider = {
        mapVar: AmCharts.maps.irelandHigh,
        getAreasFromMap: false,  
    };

    map.dataProvider = dataProvider;

    map.areasSettings = {
        autoZoom: false,
        color: "#CDCDCD",
        colorSolid: "#5EB7DE",
        selectedColor: "",
        outlineColor: "#666666",
        rollOverColor: "#88CAE7",
        rollOverOutlineColor: "#FFFFFF",
        selectable: false,
    };

    map.addListener("click", click);
    map.write("mapdiv");

    function click() {
        //Can i get long and lat here?

    };
});

 </script>
Was it helpful?

Solution 2

Ok, I found it.

Code:

 map.addListener("click", function (event) {
         var s = map.getDevInfo();
         // then you can access s.Longitude or zoomLongitude
});

OTHER TIPS

I didn't use this map control, but I ever used google map, so I think maybe you can try this:

map.addListener("click", function (e) {
//get lat and lng from e object
var latLng = e.latLng;

});

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top