Can't get a map to display on Android 2.3 - javascript

The following code works nicely on the iPhone simulator but, on Android 2.3, I just get a blank map with the Google logo on it (see attached screenshot).
var mainWin = Ti.UI.createWindow({backgroundColor:'#fff', fullscreen:true, navBarHidden: true})
mainWin.open();
var win = mainWin;
var mapview = Titanium.Map.createView({
mapType: Titanium.Map.STANDARD_TYPE,
region:{latitude:33.74511, longitude:-84.38993, latitudeDelta:0.5, longitudeDelta:0.5},
animate:true,
regionFit:true,
userLocation:true
});
win.add(mapview);
Any idea what's going on?

When you use the SDK you get this when you are missing the maps api key. You could try looking into that.
Also are you using the android emulator? Because if you are, you need to verify that your images has the google apis.

Related

Google Map (with API Key) not showing in sap.ui.vbm.GeoMap library in SAPUI5

I am trying to use Google Maps (with API key) as a map provider in sap.ui.vbm.GeoMap library in SAPUI5, but the maps are not being displayed. My API key is correct (checked with Google maps extension) and no error in console.
If I change my source URL to “https://mt.google.com/vt/x={X}&y={Y}&z={LOD}“, the map is being displayed, but I am not sure if this can be used for a production environment as this doesn’t have an API key. This is how I am using it in mapconfig:
var oMap = new sap.ui.vbm.GeoMap();
var oMapConfig = {
“MapProvider”: [{
“Id”: “GM”,
“name”: “Google Maps”,
“minLOD”: “1”,
“maxLOD”: “19”,
“tileX”: “256”,
“tileY”: “256”,
“copyright”: “© Google Maps”,
“Source”: [{
“id”: “a”,
“url”: “https://maps.googleapis.com/maps/api/js?key=My_API_Key”
}]
}],
“MapLayerStacks”: [{
“name”: “Default”,
“MapLayer”: [{
“name”: “Default”,
“refMapProvider”: “Google Maps”,
“opacity”: “1.0",
“colBkgnd”: “RGB(255,255,255)”
}]
}]
};
oMap.setMapConfiguration(oMapConfig);
oMap.setRefMapLayerStack("Default");
Can someone help me with this, what I might be doing wrong or need to change? When I use Open Street Map in the same way, it works fine but not with Google Maps
I don't know if you still need an answer, but I just had some difficulties too with the implementation of the Google Maps API to the Geomap control of SAPUI5. I was able to find the solution so I'll write it down here for you and other developers.
Your code to config the map is fine, you only need the correct Source URL. This URL is very similar to the one you would change to get the map to be displayed.
https://mt1.googleapis.com/vt?x={X}&y={Y}&z={LOD}&key=API_KEY
Change 'API_KEY' to your key and you should be good to go.

Using API Key to generate chart for external site but showing login screen

I'm trying to create a burndown chart on a webapp and using the loginkey example code, but switched loginkey to apikey (code below). My API Key is placed where it says CorrectAPIKeyHere, and actual id's for workspace_id and project_id. I have double checked to make sure it's the correct key. Here's what shows up: http://pasteboard.co/P3WXWgPk.png
However, the code works if I'm already logged into Rally. Is there anything I'm missing from my code?
<script type="text/javascript" src="https://rally1.rallydev.com/apps/1.26/sdk.js?apiKey=CorrectAPIKeyHere"></script>
<script type="text/javascript" src="https://rally1.rallydev.com/apps/1.26/sdk.js"></script>
<script type="text/javascript">
function initPage() {
console.log(gon.project_oid);
var rallyDataSource = new rally.sdk.data.RallyDataSource("workspace_id", project_id,"true","false");
console.log($(main_content).width());
var config = {
report: rally.sdk.ui.StandardReport.IterationBurndown,
height: 400,
iterations: iteration_id
};
var report = new rally.sdk.ui.StandardReport(config);
report.display("burndown_chart");
}
rally.addOnLoad(initPage);
</script>
Unfortunately there are a couple different things contributing to your current bad times. API Keys are not supported in App SDK 1.x. They are also not supported by the Analytics1 service which backs that StandardReport component.
So the only way forward is to go back to using LoginKey, which comes with the usual caveats about security, etc. Did you have a working app with LoginKey?
Good news! Api Keys are fully supported now in App SDK 2.1 and the StandardReport component so it should be totally possible to do this now.
Some useful links:
Embedding apps externally:
https://help.rallydev.com/apps/2.1/doc/#!/guide/embedding_apps
The StandardReport component:
https://help.rallydev.com/apps/2.1/doc/#!/api/Rally.ui.report.StandardReport

Google Maps in IE11 gives "Unspecified error"

I'm getting a very strange error when using custom Google Maps in a website of one of our clients. The map has some markers on it, and when you open the marker you can see a dialog with the address of that location. When I close this dialog (obviously by clicking the cross) in IE11, I get an "Unspecified error". For some reason, this error is being thrown from the method "getBoundingClientRect()". No other browser has this issue (not even IE8).
I am using Google Maps API version 3.14.
Does anyone know what this could be? I'm not sure if it's necessary to place any code, but I'm willing to do that if that makes everything more clear.
You can use this fix for IE (place this code on top):
HTMLElement.prototype._getBoundingClientRect=HTMLElement.prototype.getBoundingClientRect;
HTMLElement.prototype.getBoundingClientRect = function() {
try {
return this._getBoundingClientRect();
} catch(e) {
return { top : this.offsetTop, left : this.offsetLeft };
}
}

Getting the contents of the toolbar search box using the Mozilla Firefox Add-on SDK

I am developing a Firefox addon and I was wondering how to get the contents of the search box in the toolbar using the Mozila Addon SDK? I finally found the chrome URL where it resides (at least I think: chrome://browser/content/search/...), but I’m still a little unsure as to how to reference this to get the contents of the search box into my addon. I tried: document.getAnonymousElementByAttribute(this, "anonid", "searchbar-textbox"); but this gives a “document is not defined” error, probably because Firefox has no idea what ‘searchbar-textbox’ is and this is outside the scope of the addon (in a different ‘document’). I’m relatively new to addon development, so there’s probably a fairly straight forward way to do this, it is just that this solution is unknown to me. Thanks.
Your "main" module (and other lib/ modules) do not have any document attached. You need to first use some low-level API such as the window/utils .getMostRecentBrowserWindow() function to obtain the DOMWindow for the active browser window. After that it's just getting the #searchbar element and checking the .value property (exposed through XBL).
Complete example:
const {getMostRecentBrowserWindow} = require("window/utils");
require("sdk/widget").Widget({
id: "log-search-field",
label: "Log Search Field",
contentURL: "http://www.mozilla.org/favicon.ico",
onClick: function() {
let win = getMostRecentBrowserWindow();
console.error("Search text: " + win.document.getElementById("searchbar").value);
}
});

Bing maps api works on pc but not mobile web app

I really hope someone can help with my problem. I have built a mobile web app http://ufa-ld-qa.azurewebsites.net/ (the QA site) with asp.net mvc4 using Bing Maps API for various functionality in the app. I am having problems with the directions module. When I view the site on my pc (Chrome and IE) it works fine and I see no errors but on mobile devices it is not working (but it did work fine yesterday when we launched to QA). I have used HTML5 geolocation (this may be the issue) to get user's location to allow them to get directions to a location. I will post my code below and if anyone could please help me it would be greatly appreciated. We have tested it on about 7 different mobile devices with different OS's and it doesn't work on any. Does anyone know if this is a Bing issue or my code below? Thanks so much in advance.
<script type="text/javascript">
var map = null;
var directionsManager = null;
var userLat = null;
var userLong = null;
var userPosition = null;
var latlng = new Microsoft.Maps.Location(#Model.latitude, #Model.longitude);
navigator.geolocation.getCurrentPosition(locationHandler);
function locationHandler(position)
{
userPosition = new Microsoft.Maps.Location(position.coords.latitude, position.coords.longitude);
}
function GetMap() {
// Initialize the map
map = new Microsoft.Maps.Map(document.getElementById("map"), { credentials: "Au_7giL-8dUbFkJ8zLjcQKy4dV2ftPfpMxQ0_sVBksoj4Y-1nBT00Z1oqUIU894_",
mapTypeId: Microsoft.Maps.MapTypeId.road});
Microsoft.Maps.loadModule('Microsoft.Maps.Directions', { callback: directionsModuleLoaded });
}
function directionsModuleLoaded() {
// Initialize the DirectionsManager
directionsManager = new Microsoft.Maps.Directions.DirectionsManager(map);
// Create start and end waypoints
var startWaypoint = new Microsoft.Maps.Directions.Waypoint({ location: userPosition });
var endWaypoint = new Microsoft.Maps.Directions.Waypoint({ location: latlng });
directionsManager.addWaypoint(startWaypoint);
directionsManager.addWaypoint(endWaypoint);
// Set request options
directionsManager.setRequestOptions({ routeMode: Microsoft.Maps.Directions.RouteMode.driving });
// Set the render options
directionsManager.setRenderOptions({
itineraryContainer: document.getElementById('directionPanel'),
displayWalkingWarning: false,
walkingPolylineOptions: { strokeColor: new Microsoft.Maps.Color(200, 0, 255, 0) },
});
// Specify a handler for when an error occurs
Microsoft.Maps.Events.addHandler(directionsManager, 'directionsError', displayError);
// Calculate directions, which displays a route on the map
directionsManager.calculateDirections();
}
function displayError(e) {
// Display the error message
alert(e.message);
}
</script>
A couple of things to try. First ensure that your app is allowed to access the users location. Most mobile platforms require you to mark that the app requires access to the GPS in the manifest. Another thing to look into is the possibility that the userLocation isn't populated before your callback for the directions manager is called. It's possible that the GPS takes a little longer on the mobile device to find the users location and as such the directions loaded function is firing before the users location is set, thus passing in a null starting . You might find it useful to have a flag to indicate that the directions manager has loaded and a simple function that runs after setting the flag and also runs after setting the use location that checks that both the directions manager has loaded and the user location has been set and then calls your directions loaded function.
My Windows Phone 8 App is experiencing similar behavior. (Nokia 920)
http://bing.com/maps/default.aspx?cp=47.677797~-122.122013&lvl=12
When the Website preference is set to 'desktop version' the map renders correctly.
When the Website preference is set to 'mobile version' the map renders incorrectly.
Just started happening about a week ago !

Categories

Resources