GeoCoding Java Script

356 views
Skip to first unread message

vickir...@gmail.com

unread,
May 14, 2015, 11:45:15 PM5/14/15
to suppor...@runmyprocess.com
The getElementById in geo-coding is always NULL. See attached.

If I test the script in the JS Console and "hard code" the address I get the latitude and longitude returned. See attached.

The WI field with the address has the identifier the same as in the java script. See attached. It is "address_id" but I also had it as "id_address" and neither work.

When I run it it fails with null address_id. See attached.

I cannot see my error.

Eventually, the address will not be a WI field. It will be retrieved from Salesforce for customers to be visited but I need to use the WI field for initial demonstrations.


Addresss Field.JPG
Hardcoded Address.JPG
JS.JPG
ProcessVariables.JPG
Script Error.JPG
WI 2 with error.JPG
WI Address.JPG

Shobhit Tripathi

unread,
May 15, 2015, 4:43:36 AM5/15/15
to suppor...@runmyprocess.com
Hi Vicki,

As per the screenshot I can see you are missing "quotes".

Use this code instead - var source = document.getElementById('address_id').value;

Kindly let us know if you are still facing any issue.




--
Fujitsu - RunMyProcess
---
You received this message because you are subscribed to the Google Groups "Fujitsu RunMyProcess Developer Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to supportforum...@runmyprocess.com.
To post to this group, send email to suppor...@runmyprocess.com.
Visit this group at http://groups.google.com/a/runmyprocess.com/group/supportforum/.
To view this discussion on the web visit https://groups.google.com/a/runmyprocess.com/d/msgid/supportforum/d0e6de19-5260-4af6-ba9a-bd3bb70afc2d%40runmyprocess.com.
For more options, visit https://groups.google.com/a/runmyprocess.com/d/optout.



--
Thanks & Regards,
Shobhit
Fujitsu- RunMyProcess

vickir...@gmail.com

unread,
May 18, 2015, 2:56:35 AM5/18/15
to suppor...@runmyprocess.com
Shobhit, Again thank you for the prompt response. I am still having issues with my java script. The latitude and longitude are corrrectly calculated (see ALERT in JS which is attached) but the map is "empty". I feel I have to "return" the latitude and longitude (myLatLng) to the mapping function but I am lost where that code should go. I have tried so many options I have totally confused myself.

The JS is also attached.

Best wishes,

Vicki
Alert Lat Lng.JPG
EmptyMap.JPG
JS.JPG

Shobhit Tripathi

unread,
May 19, 2015, 5:19:19 PM5/19/15
to suppor...@runmyprocess.com
Hi Vicki,

Sorry for delay in response.

As per the last attachment(JS code) at the line 20th that is "center:new google.maps.LatLng('myLatLng')", here center (property where to center the map) accepts/pass the coordinates in the order latitude and longitude (i.e. lat: -33.8666, lng: 151.1958 ).

So instead of above code you can use like this-  center: myLatLng which will gives the proper format of coordinates as per the center property accepts.

Please refer below code for better understanding-

Example-

var geocoder = new google.maps.Geocoder();
var source = document.getElementById('id_customer_address').value

var request = {
address:source
      };
geocoder.geocode({'address': source}, function(results, status)

{
if (status == google.maps.GeocoderStatus.OK)

     {
var myLatLng = results[0].geometry.location;

          var mapOptions = {
                        center: myLatLng,
zoom:7,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('dynamic_map'), mapOptions);
     }
else
{
alert("Geocode is not successful for the following reason : "+ status);
}
}
);

Note: Make sure that you have added the proper library for Google Maps in the JavaScript tab of Web-Interface.

Hope this will helps you.

Kindly let us know if you are facing any issue.


vickir...@gmail.com

unread,
May 20, 2015, 2:45:23 AM5/20/15
to suppor...@runmyprocess.com
Again, thank you so very much for your assistance Shobhit. All is working very well and even better, I am handing the "details" of the project across to developers much better able to do the detailed scripting and HTML that will make the demonstration sing. I have proved the concepts at a high level. A good google - Salesforce integration demonstration for mobile workforce. Need to include a "behind the firewall ERP (e.g. SAP)" in the mix with SEC and we will have a real-world scenario in place.

Shobhit Tripathi

unread,
May 20, 2015, 4:30:53 AM5/20/15
to suppor...@runmyprocess.com
Hi Vicki,

Glad to know that it works.

Feel free to ask any time if you are facing any difficulties on this. 

-- 
Thanks & Regards,
Shobhit
Fujitsu- RunMyProcess

Reply all
Reply to author
Forward
0 new messages