2

Hi I am trying to find the distance between 2 location on MapQuest. I have a function

MQA.EventUtil.observe(window, 'load', function()

This function is loaded on the page load but i want it to be on a button click. Can anybody suggest me what should i need to change to have it on a button click.

Danil Speransky
  • 29,891
  • 5
  • 68
  • 79
AnuRaj
  • 233
  • 2
  • 5
  • 14

2 Answers2

0

May be

MQA.EventUtil.observe(document.getElementById('button_id'), 'click', function () {});
Danil Speransky
  • 29,891
  • 5
  • 68
  • 79
0

replace the MQA.EventUtil.observe(window, 'load', function () {with a regular function.

        function drawMap() {
            var options = {
                elt: document.getElementById('map'),            // ID of map element on page
                zoom: 7,                                        // initial zoom level of the map
                latLng: { lat: 36.1866405, lng: -86.7852455 }     // center of map in latitude/longitude
            };

. . .

Then in the body: <input id="Button1" type="button" value="GO" onclick="drawMap()" />

Don't forget to remove the ')' at the end of the MQA.EventUtil.observe(

Shelby
  • 1