loading image from a web site

71 views
Skip to first unread message

coffeeblack

unread,
Dec 29, 2010, 2:30:41 PM12/29/10
to phonegap
i am developing a mobile app for blackberry using google map api. i
thought changing an img tag src at runtime to point at my computed
google map url image is all that is needed. opening my html page on
browser works fine but compiling and deploying same on simulator will
not work.

code sample:
document.getElementById("map").src = "http://~/serve/mymap.jpg"; //
works on browser but not on simulator

document.getElementById("map").src = "resources/mymap.jpg"; //works on
simulator

at first i thought may be its my network connection failing but i have
blackberry email and mds running and i can use the simulator browser
to connect to internet.

any idea on how i can download/display image from website in my
phonegap app?


coffeeblack

Jonathan

unread,
Feb 6, 2011, 4:25:02 PM2/6/11
to phonegap

I'm having the same problem. Every image displays as a red X in the
simulator, whether it's local or from a website.

Does anyone know how to display images at all?

On Dec 29 2010, 3:30 pm, coffeeblack <aniedoziech...@gmail.com> wrote:
> i am developing a mobile app forblackberryusing google map api. i
> thought changing animg tag src at runtime to point at my computed
> google map url image is all that is needed. opening my html page on
> browser works fine but compiling and deploying same on simulator will
> not work.
>
> code sample:
> document.getElementById("map").src = "http://~/serve/mymap.jpg"; //
> works on browser but not on simulator
>
> document.getElementById("map").src = "resources/mymap.jpg"; //works on
> simulator
>
> at first i thought may be its my network connection failing but i haveblackberryemail and mds running and i can use the simulator browser

Srini

unread,
Feb 8, 2011, 4:08:49 PM2/8/11
to phonegap
Try to give a timeout so that image is preloaded.

$("#map").attr("src", "newimagepath/img.jpg")
setTimeout(function(){
$("#map").css("display", "block")
}, 600);

If images are static, you could do javascript image preload:

img = new Image()
img.src = "newimagepath/img.jpg"

and then use "newimagepath/img.jpg" at a later stage.

Both above worked well for me.


Jonathan

unread,
Feb 11, 2011, 11:23:29 AM2/11/11
to phonegap

That's cool, thanks. :) This will definitely come in handy.

On Feb 8, 5:08 pm, Srini <vas...@gmail.com> wrote:
> Try to give a timeout so thatimageis preloaded.
>
> $("#map").attr("src", "newimagepath/img.jpg")
> setTimeout(function(){
>                     $("#map").css("display", "block")
>             }, 600);
>
> If images are static, you could do javascriptimagepreload:
>
> img = newImage()
> img.src= "newimagepath/img.jpg"
Reply all
Reply to author
Forward
0 new messages