Google Java Script API Blackberry

82 views
Skip to first unread message

CrAcKeL

unread,
Feb 16, 2011, 4:54:41 AM2/16/11
to phonegap
howdy fellas,
when i have heard about Google Java Script API V 3's support for the
Blackberry OS 6 , i have tired to develop one Google map application
using phonegap.But it dint worked on my 9800 simulator and is giving
me JVM 104 error .NullPointerexception error. i have added access
element in config file for maps.google.com and subdomains=true

is anyone here know how to get google maps java script api to work on
blackberry OS 6 apps ?? pls help

here i am pasting the code of my sample application, that i am using
to load google map in DIV tag,.

My code :--
=========

<!DOCTYPE HTML >
<html>
<head>

<meta name="viewport" content="width=device-width; height=device-
height; user-scalable=no" />
<meta http-equiv="Content-type" content="text/html;
charset=utf-8">
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0px; padding: 0px }
#map_canvas { height: 100% }
</style>
<title>Remind Me</title>
<link rel="stylesheet" href="/master.css" type="text/css"
media="screen" />
<script type="text/javascript" src="scripts/phonegap.js"></script>
<script type="text/javascript" src="http://maps.google.com/maps/
api/js?sensor=false"></script>
<script type="text/javascript">
function loader() {
var state = document.readyState;
if (state == 'loaded' || state == 'complete') {
run();
} else {
if (navigator.userAgent.indexOf('Browzr') > -1) {
setTimeout(run, 250);
} else {
document.addEventListener('deviceready',run,false);
}
}

}

function run() {
var win = function(position)
{
// Grab coordinates object from the Position object passed into
success callback.
var coords = position.coords;
alert('Latitude: ' + position.coords.latitude +
'\n' +
'Longitude: ' + position.coords.longitude +
'\n' +
'Altitude: ' + position.coords.altitude +
'\n' +
'Accuracy: ' + position.coords.accuracy +
'\n' +
'Altitude Accuracy: ' + position.coords.altitudeAccuracy +
'\n' +
'Heading: ' + position.coords.heading +
'\n' +
'Speed: ' + position.coords.speed +
'\n' +
'Timestamp: ' + new Date(position.timestamp) +
'\n'
);
var map_canvass = initialize(coords.latitude,coords.longitude);
};
var fail = function(e) {
alert('Can\'t retrieve position.\nError: ' +
e);
};
var options = {};
options.enableHighAccuracy = true;
options.timeout = 30*1000;
navigator.geolocation.getCurrentPosition(win, fail,options);
}

function initialize(latitude,longitude) {
alert(latitude+"==="+longitude);
var latlng = new google.maps.LatLng(latitude,longitude);
//var latlng = new google.maps.LatLng(-34.397, 150.644);
var myOptions = {
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new
google.maps.Map(document.getElementById("map_canvas"),myOptions);
}
</script>
</head>
<body onload="loader();">
<div id="map_canvas" style="width:100%; height:90%" >Out of Luck</
div>
</body>
</html>

Justin Tyberg

unread,
Feb 16, 2011, 7:15:59 AM2/16/11
to phonegap
First of all, it's important to understand that this code, as written,
doesn't even use PhoneGap.

The BlackBerry 6 browser has its own implementation of
navigator.geolocation. Even if you include phonegap.js, it won't
stomp on BB's implementation. See this link for a more detailed
explanation of geolocation options on BlackBerry:

http://wiki.phonegap.com/w/page/32351128/Geolocation,-PhoneGap-and-BlackBerry-WebWorks

If you decide to override the BB implementation and use PhoneGap's
implementation instead, you'll have to include json2.js as well.

I haven't tried your code yet. At which point is it failing?

Robert Fletcher

unread,
Feb 16, 2011, 8:57:05 AM2/16/11
to phon...@googlegroups.com

map_canvas is spelled map_canvass in the js. could be a problem.

> --
> You received this message because you are subscribed to the Google
> Groups "phonegap" group.
> To post to this group, send email to phon...@googlegroups.com
> To unsubscribe from this group, send email to
> phonegap+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/phonegap?hl=en?hl=en
>
> For more info on PhoneGap or to download the code go to www.phonegap.com

Element Cracker

unread,
Feb 17, 2011, 6:51:48 AM2/17/11
to phon...@googlegroups.com, Justin Tyberg
Hey Justing ..
thnf for the help..
i have added json2.js java script file to use the phonegap's geolocation api.and then i have run the my application. but still my application was exiting non gracefully  saying  JVM 104 error uncaught null pointerexception

i have did some debuging and found that  google.maps.LatLng(latitude,longitude) function was using  data from maps.gstatic.com so i have added that in access and also after that i was not able to load the image and Google was using map.googleapis.com domain for that so i have added that also in my config.xml file

now i am able to load proper Google map on my simulator though when it starts loading the map it throws some uncaught null pointer exception error but if i click continue for thee to 5 time then it loads the map and then  i can change the map type from terrain , setelite ..etc , i can zoom in and out the map ..(some times it throws uncaught nullpointer exception and i select continue and good to go) but only thing that i am not able to do move(drag) the map and even  i am not able to select the map map area , it  is not click-able at all.
so
is there any other access <element> that i need to add in config xml  because this null porinter exception is thrown only because of some access issues ? or any other walk through to make my map movable (drag-able) ? any kind of help is appreciated 

FYI :i am loading map into div tag  

regards,
CracKel

--
You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en

For more info on PhoneGap or to download the code go to www.phonegap.com



--
~~: EleMent CrAcKeL  :~~
Reply all
Reply to author
Forward
0 new messages