Untitled

 avatar
unknown
plain_text
3 months ago
2.5 kB
3
Indexable
MapView(
            modifier = Modifier.fillMaxSize(),
            mapViewProxy = mapViewProxy,
            arcGISMap = map,
            graphicsOverlays = listOf(graphicsOverlay),
            locationDisplay = locationDisplay,
            onSingleTapConfirmed = { screenCoordinate ->
                coroutineScope.launch {
                    try {
                        
                        val result = mapViewProxy.mapView?.identifyGraphicsOverlay(
                            graphicsOverlay,
                            screenCoordinate.screenCoordinate,
                            10.0,
                            false
                        )?.getOrThrow()

                        val graphic = result?.graphics?.firstOrNull()

                        graphic?.let {
                            val attr = it.attributes
                            val calloutText = buildString {
                                appendLine("OBJECTID: ${attr["OBJECTID"]}")
                                appendLine("Pipe ID: ${attr["Pipe_ID"]}")
                                appendLine("Status: ${attr["Status"]}")
                                appendLine("Start Node: ${attr["Start_Node_ID"]}")
                                appendLine("Stop Node: ${attr["Stop_Node_ID"]}")
                                appendLine("Material: ${attr["Material"]}")
                                appendLine("Design Dia: ${attr["Design_Dia"]}")
                                appendLine("Design Length: ${attr["Design_Length"]}")
                                appendLine("Zone: ${attr["ZONE"]}")
                            }
                            withContext(Dispatchers.Main) {
                            val calloutView = TextView(context).apply {
                                text = calloutText
                                setPadding(16, 16, 16, 16)
                            }

                            
                                
                                   val location = graphic.geometry?.extent?.center
                                    mapViewProxy.callOutLocation.show(calloutView,location)
                                }
                            }
                        }
                    } catch (e: Exception) {
                        Log.e("MapViewTap", "Error: ${e.message}")
                    }
                }
            }
        )
Editor is loading...
Leave a Comment