Dynamic Google Maps

Hello,

I have recently started a project where our client has a large number (>100) of remote sites in various regions. They have requested an interactive map element to indicate the location and status of these sites. I have reconfigured the Google Maps example provided in the ignition demo to work in my project. However, now I am attempting to update/add markers without refreshing the html and haven’t been able to do so. Essentially I am wondering how I can access (add and delete elements) a javascript array in the starting HTML of the web browser component with scripting?
It would be amazing if someone could point me in the right direction? (Also not interested in the Kymera map module)

Thanks in advance!

JxBrowser actually has a whole page on working with Google Maps - the sample code is in Java, but if you’re familiar with the syntax you should be able to port over to Jython fairly easily.
https://jxbrowser.support.teamdev.com/support/solutions/articles/9000012874-google-maps

2 Likes

Do you mind if I ask why you are not interested in using the Kymera Map Panel Module?

be careful, you may do all of this work and then end up running into the 2000 character limit in urls.

I had a brief play around with the Kymera Map Panel and found a disliked a couple of things including:
-No maker clustering
-There is a defined edge to the map and an infinite void of grey where users can scroll to some obscene latitude/longitude.
If these issues could be resolved I could be interested (especially the latter).

Does the url limit apply if you are not using the static maps api?

I will PM you and get you to email our lead dev.

Sorry I mistyped “marker clustering”

Does the url char limit apply when you are not using the static maps api?

I think it would depend on if Google maps has a character limit and if the jxbrowser has a character limit. I know when I fooled with this using the active-x module from many moons ago that relied on internet explorer there was definitely a 2k limit.

The jxbrowser module may not have this limitation.

It looks like google has a limitation:

URL Size Restriction

Google Static Maps API URLs are restricted to 8192 characters in size. In practice, you will probably not have need for URLs longer than this, unless you produce complicated maps with a high number of markers and paths. Note, however, that certain characters may be URL-encoded by browsers and/or services before sending them off to the API, resulting in increased character usage. For more information, see Building a Valid URL.

FWIW, the Web Browser component would only limit URLs to the max length of a Java string (approx 2^31). I can’t find info on limits internal to JxBrowser, but I’m seeing 16K thrown about for Chromium which it’s based on. So looks like the Google API limitation will be the critical one.

1 Like

I’ve managed to implement most of the functionality I require through the Browser.executeJavaScript() method.
However, I have been unable to get any feedback from the browser itself.
According to the JxBrowser documentation you need to use the Browser.executeJavaScriptAndReturnValue() method to do this, but it throws this error: ‘com.inductiveautomation.webbrowser.BrowserComponen’ object has no attribute ‘executeJavaScriptAndReturnValue’.
Any help would be great.

https://jxbrowser.support.teamdev.com/support/solutions/articles/9000013062-calling-java-from-javascript

Also you should update the code in your Google Dynamic Maps page to JXbrowser 6.1. The BrowserFunction class used in it is depreciated. My ability to translate Java is pretty poor and I’d love to be able to steal it and have it work straight away :slight_smile:

https://jxbrowser.support.teamdev.com/support/solutions/articles/9000031463-migrating-from-6-0-2-to-6-1