AnsweredAssumed Answered

Web Viewer JavaScript to Click and Return Geocode from Google map

Question asked by taylorsharpe on Apr 16, 2018
Latest reply on Apr 16, 2018 by taylorsharpe

I have a script that creates HTML for a web viewer that looks like:

 

data:text/html,<!DOCTYPE html>

<html>

<head>

  <meta http-equiv="content-type" content="text/html; charset=UTF-8" />

  <meta name="viewport" content="initial-scale=1.0" />

  <title>Google Maps Multiple Markers</title>

  <script src="http://maps.google.com/maps/api/js?sensor=false

          type="text/javascript"></script>

</head>

<body style='border: 0; margin: 0'>

  <div id="map" style="width: 669px; height: 411px;"></div>

 

  <script type="text/javascript">

    var locations = [

['<a href="fmp://somedomain/SomeFile?script=Map%20Open%20Jobs&param=Map%20go%20to%20Dispatch%20Job|!|636594639770614021111050007100207150209040311111408070211070903111312111415">(79089) 714 ROBINHOOD PL, SAN ANTONIO TX  78209 ()</a>', 29.4985241, -98.4505344, 'http://[somedomain]/Icons/BlueHome24.png', ''],

['<a href="fmp://[somedomain]/SomeFile?script=Map%20Open%20Jobs&param=Map%20go%20to%20Dispatch%20Job|!|636594644360006020008090115061210021414040508020014001413040312150506011411">(79090) 6311 PARKDALE DR, DALLAS TX  75227 ()</a>', 32.7716955, -96.7109483, 'http://[somedomain]/Icons/BlueHome24.png', ''],

['<a href="fmp://[somedomain]/SomeFile?script=Map%20Open%20Jobs&param=Map%20go%20to%20Dispatch%20Job|!|636594653540808050201080401080713040809041210150904141011011512130413061313">(79094) 1141 PINEDALE LN, DALLAS TX  75241 (368-17352)</a>', 32.6773956, -96.8061717, 'http://[somedomain]/Icons/BrownHome16.png', ''],

['<a href="fmp://somedomain/SomeFile?script=Map%20Open%20Jobs&param=Map%20go%20to%20Dispatch%20Job|!|636594660691112050803081108081005100003040209090113030812021312000206081006">(79098) 3104 SPRING GROVE DR, PLANO TX  75025 ()</a>', 33.0899943, -96.7529539, 'http://[somedomain]/Icons/BlueHome24.png', '']

    ];

 

    var map = new google.maps.Map(document.getElementById('map'), {

      zoom: 11,

      center: new google.maps.LatLng(29.4313301,-98.6231326),

      mapTypeId: google.maps.MapTypeId.ROADMAP

    });

 

google.maps.event.addListener(map, 'click', function(event) {

    window.open().document.write(location='fmp://SomeDomain/SomeFile?script=Map%20Open%20Jobs&param=' + event.latLng.lat() + ',' + event.latLng.lng());

  )};

 

  </script>

</body>

</html>

 

 

I'm working on the part in red.  What I want is when you click somewhere on the map, that it returns the Lat/Long in an FMP URL to fire off a FileMaker script.

 

If I use this, it works for giving me a Java Script prompt with the Lat/Long.

 

google.maps.event.addListener(map, 'click', function(event) {

    alert("Latitude: " + event.latLng.lat() + " " + ", longitude: " + event.latLng.lng());

  });

 

This will open a Java prompt with the Lat/Long in it.  I just need to get it to instead trigger a FMP URL so it can fire off a script.

 

Here is what the Java prompt looks like:

 

Untitled 3.png

 

Thanks.

Outcomes