Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 4152 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I'm not sure if I have the right approach here. I want to display a google map with multiple pins according to a found set (and in another instance the contents of a portal).

 

I have a script that builds some text/html using 3 Set Field statements. Each Set Field statement is just plain text.  The Set Field is then displayed by a Set Web Viewer step into an Object.

 

The 1st and 3rd steps are common javascript, the 2nd step is a javascript array of addresses which is hardcoded for now, but should eventually be constructed from the data in the found set.  With the hardcoded array the script would product the following text which will display a multi-pin map. 

data:text/html,<!DOCTYPE html>  
 <html><head><meta charset='utf-8'><title></title>
 <meta name='viewport' content='initial-scale=1.0, user-scalable=no'>
 <style type='text/css'>
 html { height: 100% }body { height: 100%; margin: 0; padding: 0 }#map-canvas { height: 100% }</style>
 <script src='https://maps.googleapis.com/maps/api/js?key=&sensor=false'></script><script>
 var geocoder;
 var map;
 function initialize() {
 geocoder = new google.maps.Geocoder();
 var latlng = new google.maps.LatLng( 43.670234 , -79.386737 );
 var mapOptions = { zoom: 11, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP }
 map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
 var locations = [            


'229 Ashworth Avenue, Toronto ON',  
'1112 Queen Street East, Toronto ON',  
'889 Yonge Street, Toronto ON',  
'1711 Melrose Avenue, Toronto ON',  
'2500 Yonge Street, Toronto ON',  
'45 First Avenue, Toronto ON'



             	];  
 var i; 
 for (i = 0; i < locations.length; i++) {  
 geocoder.geocode( { 'address': locations }, function(results, status) {  
 map.setCenter(results[0].geometry.location);
 var marker = new google.maps.Marker({ map: map, position: results[0].geometry.location });});}}  
 google.maps.event.addDomListener(window, 'load', initialize);  
 </script> 
 </head><body><div id='map-canvas'></div></body></html>

What I am trying to figure out is how to replace the hard coded array of addresses in the middle with the data from looping through the found set

 

I have tried something like this as the 2nd script step to build the array, but it is empty.


Loop
    Go To Record/Request/Page [Next; Exit after last]
    Set Field [Map::HTML; GetFieldName(Map::address) & ", " &  GetFieldName(Map::city) & ", " & GetFieldName(Map::province)]
End Loop

How should I go about this?

 

Thanks.

Posted

In case my explanation is hard to understand here is the sample database with the 2 scripts.

You should see the first script will display the map with pins.

The second script will display the map, but the address array will be empty - so no pins.

Maps.fmp12.zip

Posted

You could hardcode part A and C (in fields or variables), dynamically build up part B with the addresses from the loop within a variable, combining markup and data, and finally join A,B and C.

Posted

Yes that's precisely what I proposed.

 

What I'm looking for is the "how to" dynamically build the array from the found set.

As you stated, "dynamically build up part B with the addresses from the loop within a variable".  What is the proper syntax to do that?

 

Thanks.

Posted

I see what you've done to build the array, (although it seems a little convoluted in FM speak) how the looping works.

 

It does work - Thank You!

This topic is 4152 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.