question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't get marker image assets within WKWebView

See original GitHub issue

I’m submitting a … (check one with “x”)

  • question
  • any problem or bug report
  • feature request

If you choose ‘problem or bug report’, please select OS: (check one with “x”)

  • [] Android
  • iOS

cordova information: (run $> cordova plugin list)

cordova-plugin-background-mode 0.7.2 "BackgroundMode"
cordova-plugin-googlemaps 2.1.1 "cordova-plugin-googlemaps"

If you use @ionic-native/google-maps, please tell the package.json (only @ionic-native/core and @ionic-native/google-maps are fine mostly)

Current behaviour: X-Code stops in an exception throwing the following message:

Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[NSCache setObject:forKey:cost:]: attempt to insert nil value (key: http:/localhost:8080/var/containers/Bundle/Application/XXXX-XXXXXX/AppName.app/www/index.html#/./assets/icon.png)’

This happens if we specify paths like: icon: ‘assets/icon.png’, icon: ‘./assets/icon.png’, icon: ‘/assets/icon.png’, icon: file:///assets/icon.png, etc etc.

Expected behavior:

Assets should be loaded the same way that every other element does, e.g.

Related code, data or error log (please format your code or data):

let markerConfig = {
   icon: "assets/icon.png"
};

this.map.addMarker({
   title: 'xxxx',
   icon: markerConfig.icon,
   position: {...}
};

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
pabloweinxcommented, Jan 25, 2018

Apologize for the delay. I’ll try it in our next version, the current one is in production (using the UIWebView and the project is private, I would wish you to see the code and behaviour. I will keep in touch and answer you. Thanks!

0reactions
MaximeLassalleHubcommented, Oct 23, 2019

Hi there,

This is my solution to get WkWebView (plugin v2) to work with custom marker images :

The path for iOS & Android is a bit different, as it has to include ‘www’ for iOS and starts with ‘./’ in both cases.

get rootAssetPath() { if (this.platformServ.android()) { return ‘./assets’ } else if (this.platformServ.ios()) { return ‘./www/assets’ } else { return ‘./assets’ } }

Hope it’d be useful.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to access image resource in asset catalog from ...
The simplest solution is to NOT use the asset catalog for images you'll show in a web view. If keeping the images in...
Read more >
load image center in wkwebview | B4X Programming Forum
this happens only if i use file.dirdocument. from file.dirassets it works fine. the info of Powerview says the the path is relative to...
Read more >
Failed to load assets image with Version > 10 #1316 - GitHub
I'm currently migrating my project to cordova-android@10 . In my Project i'm using Googlemaps and Markers that icons are in my assets Folder....
Read more >
WKWebView | Apple Developer Documentation
An object that displays interactive web content, such as for an in-app browser.
Read more >
WKWebView load files from both Bundle and Document ...
Downside: it exposes Web_assets files in user accessible Documents folder. But they can't be altered since they are replaced on App start.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found