@@ -11,6 +11,7 @@ import androidx.annotation.RestrictTo
1111import androidx.annotation.VisibleForTesting
1212import androidx.annotation.VisibleForTesting.Companion.PRIVATE
1313import com.mapbox.maps.plugin.MapPlugin
14+ import com.mapbox.maps.plugin.Plugin
1415import com.mapbox.maps.plugin.delegates.MapPluginProviderDelegate
1516import com.mapbox.maps.renderer.*
1617import com.mapbox.maps.renderer.widget.Widget
@@ -346,7 +347,7 @@ class MapSurface : MapPluginProviderDelegate, MapControllable {
346347 /* *
347348 * Add an instance of [RendererSetupErrorListener].
348349 *
349- * Please note that errors could be already reported from the renderer during [MapView ] creation
350+ * Please note that errors could be already reported from the renderer during [MapSurface ] creation
350351 * before this method will be called - all accumulated renderer errors will be delivered.
351352 */
352353 override fun addRendererSetupErrorListener (rendererSetupErrorListener : RendererSetupErrorListener ) {
@@ -360,6 +361,25 @@ class MapSurface : MapPluginProviderDelegate, MapControllable {
360361 mapController.removeRendererSetupErrorListener(rendererSetupErrorListener)
361362 }
362363
364+ /* *
365+ * Create a new plugin instance that will be added to the map.
366+ * Only one instance of [Plugin.instance] with given [Plugin.id] can exist for given [MapSurface].
367+ *
368+ * @param plugin instance of [Plugin] that will be added to the [MapSurface].
369+ */
370+ fun createPlugin (
371+ plugin : Plugin
372+ ) = mapController.createPlugin(null , plugin)
373+
374+ /* *
375+ * Remove the plugin instance that will be removed from the map.
376+ *
377+ * Removing the plugin from [MapSurface] will result in [MapPlugin.cleanup] being called and existing
378+ * events subscription cancelled.
379+ *
380+ * @param id the id of the plugin to be removed
381+ */
382+ fun removePlugin (id : String ) = mapController.removePlugin(id)
363383 /* *
364384 * Get the plugin instance.
365385 *
0 commit comments