首页 > 解决方案 > 无法在googlemaps swift 5上使用geojson显示标记标题

问题描述

我正在尝试将 geojson 文件中的数据显示到谷歌地图。我有显示线,但我无法在谷歌显示数据标题这里我只有没有标题图的路径

 let path = Bundle.main.path(forResource: "dat", ofType: ".geojson")
        let url = URL(fileURLWithPath: path!)
        geoJsonParser = GMUGeoJSONParser(url: url)
        geoJsonParser.parse()
        renderer = GMUGeometryRenderer(map: mapKitC, geometries: geoJsonParser.features)
        for i in geoJsonParser.features {
            if let feature = i as? GMUFeature {
                let properties = feature.properties
                //print(properties?["Name"]! ?? [String:AnyObject]())
                print((properties?["Name"] as! String))
                i.style = GMUStyle(styleID: "feat_1", stroke: UIColor.red, fill: .clear, width: 2, scale: 1, heading: 1, anchor: CGPoint.zero, iconUrl: nil, title: (properties?["Name"] as! String) , hasFill: true, hasStroke: true)
            }
        }

这是geojson文件中的一个简单的json

{“类型”:“FeatureCollection”,“名称”:“Export_Output_2”,“crs”:{“类型”:“名称”,“属性”:{“名称”:“urn:ogc:def:crs:OGC: 1.3:CRS84" } }, "features": [{ "type": "Feature", "properties": { "Name": "الجزيرة", "description": null, "altitudeMode": "clampToGround", "REMARKS “:“الجزيرة”,“FID”:“1”,“Field_1”:“الجزيرة”},“几何”:{“类型”:“多多边形”,"coordinates": [ [ [ [50.016116765605382, 26.55069039986865], [50.015975528609339, 26.550991875762669], [50.015543249856229, 26.552092609191], [50.014021356227893, 26.555916886985312], [50.013986819836397, 26.555993389005849], [50.0139615327519, 26.55605189831601], [50.013937500451902, 26.556110416304062], [ 50.013914703626462,26.5561711999925231],[50.01389319093939172,26.5562297353409][50.013834177740307, 26.5564166652394], [50.010366238955562, 26.55583737812676], [50.010393511923603, 26.555767597848071], [50.010456762048257, 26.555598755587489], [50.010516559775482, 26.555429888414469], [50.010573224326002, 26.555261000355909], [50.010626464910303, 26.555089831406779], [50.010676553278628, 26.554918640545011], [50.011099741935944 , 26.553458982554702], [50.011300373154121, 26.552817103722361], [50.011331824976743, 26.55269769626123], [50.011356075862062,5208].2[50.011381863106351, 26.55253327596817], [50.011409240723651, 26.552449953630379], [50.011438194289781, 26.552366642218029], [50.01146869440673, 26.552285598614549], [50.011501071619158, 26.55220456712059], [50.01153470354334, 26.552123545223392], [50.011569892050197, 26.552044791201482], [50.011606655769612, 26.551963791005878], [50.011644976066812 , 26.551885058683109], [50.011684872292918, 26.55180633727754], [50.01172630602143, 26.55172988360998], [50.012049918940242, 172918940242, 296.[50.012152127902489, 26.550947367255439], [50.013113094152381, 26.549252177776619], [50.016116765605382, 26.55069039986865]]]]]]

标签: iosswiftgoogle-mapsgoogle-maps-markers

解决方案


推荐阅读