توضح لك هذه الصفحة كيفية عرض البيانات الجغرافية في GeoJSON
باستخدام GMUGeoJSONParser، في
بالتزامن مع GMUGeometryRenderer. يعد GeoJSON تطبيقًا شائعًا
لعرض البيانات الجغرافية مثل النقاط والخطوط والمضلّعات.
للاطّلاع على عيّنة الرموز الكاملة، يُرجى مراجعة نماذج التطبيقات
تشغيل
GitHub.
عرض بيانات GeoJSON
لعرض بيانات GeoJSON على خريطة، يمكنك إنشاء GMUGeoJSONParser باستخدام
المسار إلى مورد GeoJSON (GeoJSON_sample.kml في هذا
مثال). بعد ذلك، أنشئ GMUGeometryRenderer، مع تمرير
مثيل واحد (GMUKMLParser) أخيرًا، اتصل
GMUGeometryRenderer.render() يوضح مثال الرمز التالي
عرض بيانات GeoJSON على خريطة:
Swift
import GoogleMapsUtils
class GeoJSON {
private var mapView: GMSMapView!
func renderGeoJSON() {
guard let path = Bundle.main.path(forResource: "GeoJSON_sample", ofType: "json") else {
return
}
let url = URL(fileURLWithPath: path)
let geoJsonParser = GMUGeoJSONParser(url: url)
geoJsonParser.parse()
let renderer = GMUGeometryRenderer(map: mapView, geometries: geoJsonParser.features)
renderer.render()
}
}
تاريخ التعديل الأخير: 2024-09-05 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","easyToUnderstand","thumb-up"],["ساعَدني المحتوى في حلّ مشكلتي.","solvedMyProblem","thumb-up"],["غير ذلك","otherUp","thumb-up"]],[["لا يحتوي على المعلومات التي أحتاج إليها.","missingTheInformationINeed","thumb-down"],["الخطوات معقدة للغاية / كثيرة جدًا.","tooComplicatedTooManySteps","thumb-down"],["المحتوى قديم.","outOfDate","thumb-down"],["ثمة مشكلة في الترجمة.","translationIssue","thumb-down"],["مشكلة في العيّنات / التعليمات البرمجية","samplesCodeIssue","thumb-down"],["غير ذلك","otherDown","thumb-down"]],["تاريخ التعديل الأخير: 2024-09-05 (حسب التوقيت العالمي المتفَّق عليه)"],[[["This page demonstrates how to render geographic data in GeoJSON format on Google Maps using the `GMUGeoJSONParser` and `GMUGeometryRenderer`."],["GeoJSON is a commonly used format for displaying geographic data like points, lines, and polygons."],["You'll need to set up the Maps SDK for iOS Utility Library before using `GMUGeoJSONParser`."],["The provided code examples show how to render GeoJSON data on a map in both Swift and Objective-C."]]],["The document explains how to render GeoJSON data on a map using the `GMUGeoJSONParser` and `GMUGeometryRenderer` from the Maps SDK for iOS Utility Library. First, a `GMUGeoJSONParser` is created with the GeoJSON resource path. Then, a `GMUGeometryRenderer` is initialized with the map view and the parser's features. Finally, the `GMUGeometryRenderer.render()` method is called to display the GeoJSON data, such as points, lines, and polygons, on the map.\n"]]