OpenLayers Add Overlay

24 views
Skip to first unread message

Joseph Gutenson

unread,
Sep 12, 2016, 11:06:37 AM9/12/16
to Tethys Platform
Hi All,

New to JS and have a question regarding OpenLayers.

It is my understanding that the method 
TETHYS_MAP_VIEW.getMap();
is essentially the
ol.map();
method.  

Is there a Tethys equivalent for
ol.overlay();
?

More generally, how do I interact with OpenLayers without using the Gizmos API?

Thanks in advance,
Joseph

swainn

unread,
Sep 12, 2016, 11:29:44 AM9/12/16
to Tethys Platform
Joseph,

You are on the right track. The getMap() method should return the map object that should contain all the information about the map being rendered on the page. Here is a link to the documentation on that method: http://docs.tethysplatform.org/en/latest/tethys_sdk/gizmos/map_view.html#javascript-api In the explanation of the getMap() method there is also a link to the API documentation for the ol.Map object (http://openlayers.org/en/v3.10.1/apidoc/ol.Map.html). On the left you will see the methods that you can call on that object (e.g.: getLayers, addLayer, getOverlays). It is very important that you use the documentation for the correct version of OpenLayers (which at the time of writing was 3.10.1). If you use Google to search for solutions, be careful to specify "openlayers 3" in your search, otherwise you will get a lot of results based on the old OpenLayers 2, which is very different. I would also encourage you to peruse the examples page: http://openlayers.org/en/v3.10.1/examples/

Hope this helps!

Joseph Gutenson

unread,
Sep 13, 2016, 4:28:45 PM9/13/16
to Tethys Platform
Hey Nathan,

Thanks for the quick reply!  Alan showed me how to toggle the OpenLayers overlay but he also showed me how he was using modals to do something similar in one of his apps.  I just now got that to work properly (not sure how though! :-)).

Thanks again,
Joseph
Reply all
Reply to author
Forward
0 new messages