06-29-2011 05:01 AM
Hi,
I cannot get google maps to display even in the emulator although it works fine when looking at this page in a browser. OS 6
See my code below:
<!DOCTYPE html>
<html>
<head>
<title>MapTest</title>
<script src="jquery-1.6.1.min.js" type="text/javascript"></script>
<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
if (navigator.geolocation) {
var lat = 0,
lng = 0;
var myOptions = {
zoom: 10,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map-canva s"), myOptions);
function setCurrentLocation() {
var latlng = new google.maps.LatLng(lat, lng);
map.setCenter(latlng);
// Add a marker using the user_lat_long position
var marker = new google.maps.Marker({
position: latlng,
animation: google.maps.Animation.DROP,
map: map
});
}
function gpsSuccess(pos) {
if (pos.coords) {
lat = pos.coords.latitude;
lng = pos.coords.longitude;
setCurrentLocation();
}
else {
lat = pos.latitude;
lng = pos.longitude;
}
}
function gpsFail() {
//Geo-location is supported, but we failed to get your coordinates. Workaround here perhaps?
}
navigator.geolocation.getCurrentPosition(gpsSucces s, gpsFail, { enableHighAccuracy: true, maximumAge: 300000 });
}
});
</script>
</head>
<body>
<div id="map-canvas" style="height: 300px; width: 300px;">
<!-- map loads here... -->
</div>
</body>
</html>and I have added the access elements to the config file:
<?xml version="1.0" encoding="utf-8"?> <widget xmlns=" http://www.w3.org/ns/widgets" xmlns:rim="http://www.blackberry.com/ns/widgets" version="2.0" rim:header="RIM-Widget: rim/widget"> <rim:navigation mode="focus" /> <name>MapTest</name> <content src="Index.htm"/> <feature id="blackberry.ui.dialog" required="true" version="1.0.0"/> <access subdomains="true" uri="http://gstatic.com"/> <access subdomains="true" uri="http://google.com"/> <access subdomains="true" uri="http://googleapis.com"/> </widget>
If anyone can help I would really appreciate it. Thanks
06-29-2011 07:42 AM - edited 06-29-2011 07:43 AM
It looks like you haven't added http://maps.google.com to your <access> list. Give that a try or whitelist * to see if it is a whitelisting issue.
06-29-2011 07:54 AM
Hi,
I have tried adding it to the config but still no joy.
Any other ideas?
06-29-2011 07:59 AM
<?xml version="1.0" encoding="utf-8"?> <widget xmlns=" http://www.w3.org/ns/widgets" xmlns:rim="http://www.blackberry.com/ns/widgets" version="2.0" rim:header="RIM-Widget: rim/widget"> <rim:navigation mode="focus" /> <name>MapTest</name> <content src="Index.htm"/> <feature id="blackberry.ui.dialog" required="true" version="1.0.0"/> <access subdomains="true" uri="*"/> <!--<access subdomains="true" uri="http://gstatic.com"/> <access subdomains="true" uri="http://google.com"/> <access subdomains="true" uri="http://googleapis.com"/>--> </widget>
I have changed my config to the above but still no map
06-29-2011 08:00 AM
06-29-2011 08:11 AM
It is v2 of the sdk.
Thanks for helping I really want to get to the bottom of this.
I still cant find the answer
06-29-2011 08:36 AM
This is crazy! So frustrating! It should be easy!
06-29-2011 08:41 AM
06-29-2011 08:43 AM
I have tried renaming the jquery js file too but no difference.
The code is now as follows:
<!DOCTYPE html>
<html>
<head>
<title>MapTest</title>
<script src="jquery.js" type="text/javascript"></script>
<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
if (navigator.geolocation) {
var lat = 0,
lng = 0;
var myOptions = {
zoom: 10,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map-canva s"), myOptions);
function setCurrentLocation() {
var latlng = new google.maps.LatLng(lat, lng);
map.setCenter(latlng);
// Add a marker using the user_lat_long position
var marker = new google.maps.Marker({
position: latlng,
animation: google.maps.Animation.DROP,
map: map
});
}
function gpsSuccess(pos) {
if (pos.coords) {
lat = pos.coords.latitude;
lng = pos.coords.longitude;
setCurrentLocation();
}
else {
lat = pos.latitude;
lng = pos.longitude;
}
}
function gpsFail() {
//Geo-location is supported, but we failed to get your coordinates. Workaround here perhaps?
}
navigator.geolocation.getCurrentPosition(gpsSucces s, gpsFail, { enableHighAccuracy: true, maximumAge: 300000 });
}
});
</script>
</head>
<body>
<div id="map-canvas" style="height: 300px; width: 300px;">
<!-- map loads here... -->
</div>
</body>
</html>
<?xml version="1.0" encoding="utf-8"?> <widget xmlns=" http://www.w3.org/ns/widgets" xmlns:rim="http://www.blackberry.com/ns/widgets" version="2.0" rim:header="RIM-Widget: rim/widget"> <rim:navigation mode="focus" /> <name>MapTest</name> <content src="Index.htm"/> <feature id="blackberry.ui.dialog" required="true" version="1.0.0"/> <access subdomains="true" uri="*"/> <!--<access subdomains="true" uri="http://gstatic.com"/> <access subdomains="true" uri="http://google.com"/> <access subdomains="true" uri="http://googleapis.com"/>--> </widget>
Can anyone help before I pull out the last of my hair???
06-29-2011 08:46 AM
It works in desktop browsers firefox, chrome and chrome with Ripple blackberry webworks emulator (not the sdk emulator).