I exported a layer and features attribute to PDF using ArcGis software. And now, I would like to build an iOS app that I can load this map offline. as I just have started to use ArcGis for iOS, I tried tried this code and I could'n see this map:
override func viewDidLoad() {
super.viewDidLoad()
self.map = AGSMap(basemap: AGSBasemap.topographic())
self.mapView.map = map
let path = Bundle.main.url(forResource: "Map1", withExtension: "pdf")
let localTiledLayer = AGSArcGISTiledLayer(tileCache: AGSTileCache(fileURL: path!))
self.mapView.map = map
map.operationalLayers.add(localTiledLayer)
}
How do I load this pdf file? Thanks.
PDF maps are not supported by the Runtime.
If you want to export feature data, you should use Mobile Map Packages, which can be generated by ArcGIS Pro. They package up a map (or many maps) with data, symbology, popup configuration etc. and can be opened using the AGSMobileMapPackage class.
If you are using ArcMap, then you could export a Runtime Geodatabase and open that using the AGSGeodatabase class, but Mobile Map Packages provide more capabilities in a single file rather than having to create maps and load layers from various sources.
This video gives a good overview of what's possible, and you can read more here.
Related
I have an epub file in the project and I would like to open it with in the application i have tried using "EpubExtractor" pod but no use.
Now I am trying to achive that if i can use the path to view that file on the webview.
guard let resourceUrl = Bundle.main.url(forResource: "Sway",withExtension: "epub") else {return}
webView.loadFileURL(resourceUrl,allowingReadAccessTo: resourceUrl)
path I am getting.
file:///Users/apple/Library/Developer/CoreSimulator/Devices/4203B9E1-E3A4-4636-8750-E5340AAD51ED/data/Containers/Bundle/Application/F3BF662A-34AD-44C0-AFD9-E4BB7AD74551/EpubWebView.app/Sway.epub
When I am using the above code i am not able to view anything on the webview as it gives me an error "not able to load in webview"
ePub format is not supported by the WKWebView framework. You can search Apple or webkit.org to see the core features of WKWebView
I am trying to build a translator application in swift and for that I have decided to go with Google Translate Api. I was searching for ways to provide user with offline translation functionality.
I was unable to find any documentation about the same.
Can anyone help me explore more on this issue and how to achieve it?
I believe you need to download the language files.
Have a look at this google translate Download languages to use offline
After a bit of research Google provide some thing called on-device translation. ML Kit's on-device translation API
According to the documentation you can download the files following
// Download the French model.
let frModel = TranslateRemoteModel.translateRemoteModel(language: .fr)
// Keep a reference to the download progress so you can check that the model
// is available before you use it.
progress = ModelManager.modelManager().download(
frModel,
conditions: ModelDownloadConditions(
allowsCellularAccess: false,
allowsBackgroundDownloading: true
)
)
And to translate
englishGermanTranslator.translate(text) { translatedText, error in
guard error == nil, let translatedText = translatedText else { return }
// Translation succeeded.
}
References = Translate text with ML Kit on iOS
Also have a look at the Example Project Provided by google - Swift 5
I load an MBTiles Vector Tile data source of my country, using carto-mobile SDK
// Initialize base layer with a bundled styles
let baseLayer = NTCartoOnlineVectorTileLayer(style: NTCartoBaseMapStyle.CARTO_BASEMAP_STYLE_GRAY)
// Use the style for your own vector tile datasource (online, offline etc),
let tileDataSource = NTMBTilesTileDataSource(path: Bundle.main.path(forResource: "estonia_ntvt", ofType: "mbtiles"))
// Initialize offline layer & Grab vector tile layer from our base layer
let offlineLayer = NTVectorTileLayer(tileDataSource, baseLayer?.getTileDecoder())
mapView?.layers?.add(baseLayer)
mapView?.layers?.add(offlineLayer)
and is showing everything ok, so i have my map and all the features.
So now i want to search, for a POI or a street name.
I know that an MBTiles have all the information inside him, but how can i access to that info??
Is this posible?? if it is possible, how i do that??
The latest version (4.1.0) of CARTO mobile SDK has NTVectorTileSearchService using mbtiles. There is no user doc for it yet, but sample code can be found from AdvancedMap.Swift.
// init search service with your mbtiles
searchService = NTVectorTileSearchService(dataSource: baseSource, tileDecoder: baseLayer.getTileDecoder())
// prepare search request, set some conditions.
// This search is to find attractions within 500m from a route geometry
let request = NTSearchRequest()
request?.setProjection(contentView.baseSource.getProjection())
request?.setGeometry(geometry)
request?.setSearchRadius(500.0)
request?.setFilterExpression("class='attraction'")
// actual search
let results = contentView.searchService.findFeatures(request)
let count = Int((results?.getFeatureCount())!)
// go through found items
for i in 0..<count {
let item = results?.getFeature(Int32(i))!
if (item?.getGeometry() is NTPointGeometry) {
contentView.addPOI(feature: item!)
}
}
Note that this Search service is more usable for POI or street geometry search. Also be aware that same street is often duplicated in different tiles, and big polygons are often partial in tiling.
By geocoding we mean a bit different things - search for human-readable addresses or search for address given a location (reverse-geocode). MBTiles/Vector tiles does not have full data for this, it optimized for visual look. For example building or address points may have house number tag, but almost never have streets or city and country data in them, as it would be redundant and not needed for visual maps. Now for literal geocoding CARTO SDK has solution also: NTGeocodingService. You can use this online or offline, just for the offline case SDK has to download special different data packages per country (or city if you want). These data packages have full hierarchical address data, so real geocoding would work with them. So for complete offline data you would need to get two offline packages separately: mbtiles for maps and geocoding database. If you want offline routing also, then third dataset, as this also cannot be done properly from mbtiles/vector tiles alone.
This is very new feature, so you need to use pre-release version of SDK, but your feedback is very welcome.
My code is as below:
/* Map */
mapView = GMSMapView()
mapView.delegate = self
mapView.mapType = .normal
do {
// Set the map style by passing the URL of the local file.
if let styleURL = Bundle.main.url(forResource: "styles", withExtension: "json") {
mapView.mapStyle = try GMSMapStyle(contentsOfFileURL: styleURL)
} else {
NSLog("Unable to find styles.json")
}
} catch {
NSLog("One or more of the map styles failed to load. \(error)")
}
I am following this tutorial on how to customize my Google map.
Above is my code for implementing the styles.json file. I added the file in my build bundle, and the code never throws an exception regarding not being able to parse my json file. It simply does not apply the style effects onto my map.
Any help would be appreciated. I am slowly dying inside!!!
Leaving an answer for anyone in the future that goes down my path:
Google map styling does not work for maps of South Korea. It even works in North Korea, but not South. South Korea's law prohibits map data from being exported to foreign datacenters.
source:
Yes , Korea does not support some features offered by Google Map due to national law. Google Map Korea can not be export map data for data centers abroad or including the ability to dynamically change the map image. Many South Korea Maps and services are limited to the domestic uses and Google is striving to make this a better service. For more details here's the original answer in Korean: original reply from Google Maps Korea
I am implementing Google Maps in my iOS App. I want to remove certain labels from the map. I want to keep street names but want to remove malls, temples, restuarents etc labels from the map. How can i do this?
I got it. We can style our maps using Map styles.check this link Just Style and download the json. Copy the json file into project and set the style like this:
if let stylesFile = Bundle.main.url(forResource: "style", withExtension: "json")
{
mMapView.mapStyle = try! GMSMapStyle.init(contentsOfFileURL: stylesFile)
}