Local Icon with HTML

tudorf

Active Member
Licensed User
Longtime User
I want to change the Icon from the samle "GoogleMapsWebView". I have found a Thread "WebView and Google Maps".

Dim MyCar As String
MyCar="file:///android_asset/car2.png"

HtmlCode = HtmlCode & "; var markerc = new google.maps.Marker({ position: new google.maps.LatLng(" & CenterLat & "," & CenterLong & "),map: map, title: '',clickable: false,icon:'" & MyCar & "'})"


I have created a folder under my Samsung but the program shows no Icon. It shows nothing on the map.

The folder under the phone is : Phone/mnt/sdcard/Test_Mystery
The Msgbox shows : /mnt/sdcard/Test_Mystery

' Dim cicon2 As String : cicon2 = File.DirDefaultExternal.Trim&"/hier.png"
' Dim cicon2 As String : cicon2 = File.DirAssets.Trim&"/hier.png"
Dim cicon2 As String : cicon2 = File.DirRootExternal&"/Test_Mystery/hier.png"
' Dim cicon2 As String : cicon2 = File.DirRootExternal&"/hier.png"
' Dim cicon2 As String : cicon2 = File.DirInternal.Trim&"/hier.png"
' Dim cicon2 As String : cicon2 = "file:///android_asset/hier.png"
' Dim cicon2 As String : cicon2 = "//android_asset/hier.png"

Msgbox(cicon2,"cIcon2")
HtmlCode = HtmlCode & "; markerc = new google.maps.Marker({ position: new google.maps.LatLng(" & CenterLat & "," & CenterLong & "),map: map, title: '',clickable: false,icon: "&cicon2&" })"

I added the File "Hier.png" under B4A under files too.

Martin
 
Last edited:

mc73

Well-Known Member
Licensed User
Longtime User
Perhaps you could try copying first from dir.assets to dir.defaultExternal and then proceed. I don't know if it's the same situation, but I usually load images in html, using as their file description, this: "file://" & File.DirDefaultExternal & myFile.png
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
HtmlCode = HtmlCode & "; var markerc = new google.maps.Marker({ position: new google.maps.LatLng(" & CenterLat & "," & CenterLong & "),map: map, title: '',clickable: false,icon:'" & MyCar & "'})"

Here you're enclosing the B4A variable MyCar with single quotes.

HtmlCode = HtmlCode & "; markerc = new google.maps.Marker({ position: new google.maps.LatLng(" & CenterLat & "," & CenterLong & "),map: map, title: '',clickable: false,icon: "&cicon2&" })"

But here you're not enclosing cicon2 with single quotes.
The generated HTML will look something like:

B4X:
clickable: false,icon: /mnt/sdcard/Test_Mystery/hier.png })"

Enable the WebView WebChromeClient and you should see errors such as these logged.

You should be able to use icons from the DirAssets folder without copying them to external memory.

I added the File "Hier.png" under B4A under files too.

Did you mean Hier.png or hier.png - remember only lower case filenames are allowed.

Martin.
 
Upvote 0

tudorf

Active Member
Licensed User
Longtime User
I added not "Hier.png". I added "hier.png".
The program runs with
map: map, title: '',clickable: false,icon: '/mnt/sdcard/Test_Mystery/hier.png' })"

I want to use different icons. I use different html-codes. This is no problem.
Thanks Martin
 
Upvote 0
Top