Webworks Google map is frozen - google-maps

I am pretty new to this whole WebWorks stuff (Just started playing around with it today, getting ready for a local blackberry hackathon) and i decided to learn it by action with the google maps api to generate content for me to play with, as well as considering a WebWorks port of a maps app i'm working on for Android.
Here's the HTML:
<!DOCTYPE html>
<html>
<head>
<meta id="viewport" name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width"" />
<link href='style.css' rel='stylesheet' type='text/css'>
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=SNIP&sensor=true&language=es&region=CO">
</script>
<script type="text/javascript" src="javascript.js">
</script>
</head>
<body onload="initializeMap()">
<div id="map_canvas" style="width:100%; height:100%"></div>
</body>
</html>
The CSS:
html {
height: 100%
}
body {
height: 100%;
margin: 0;
padding: 0;
}
#map_canvas {
height: 100%
}
And the JS:
function initializeMap() {
var mapOptions = {
center: new google.maps.LatLng(6.199383, -75.578980),
zoom: 17,
mapTypeId: google.maps.MapTypeId.HYBRID
};
map = new google.maps.Map(document.getElementById("map_canvas"),
mapOptions);
google.maps.event.addListener(map, 'click', function(event) {
placeMarker(event.latLng);
});
}
function placeMarker(location) {
var marker = new google.maps.Marker({
position: location,
map: map
});
map.setCenter(location);
}
Now my question is: Why doesn't clicking or dragging the map on the Ripple emulator work? [WebWorks BB10] It works wonders on chrome, i can pan, zoom and the markers get placed when i click them.
Thanks.
Edit
The map renders fine on Ripple, but the map itself won't work, nothing happens if i click or drag around with the mouse. The Satellite, Map and zoom buttons do work though

Clicking or dragging the map on the Ripple emulator may not work for a couple of reasons:
There is a runtime error happening and something within the Google
Maps is failing. Try opening Web Inspector (right click on map in
Ripple and select "Inspect Element") to see if there are any run
time errors. It may explain why certain behavior is not working as
expected.
Touch events may not be handled correctly. Try opening Web Inspector (right click on map in Ripple and select "Inspect Element"). Then open the settings (gear in bottom right corner) and select the "Overrides" tab. Make sure that the "Emulate touch events" checkbox is enabled.
Hope that helps.

Related

Google Maps API v3.22 script error when dropping the little man onto a road

Since the latest release (on Tuesday) of the Google Maps API, every time I drag the little man onto a road and drop it, I get a script error (http://maps.googleapis.com/maps-api-v3/api/js/22/7/intl/en_gb/util.js). The Street View then displays fine - but there is no Address Control and therefore no way to exit from Street View!
A similar script error also happens when specifying v3.23 (the error is http://maps.googleapis.com/maps-api-v3/api/js/23/7/intl/en_gb/util.js instead)!
However, if I set the controlStyle to 'azteca' everything works fine. As this setting will be removed in August, I'm keen to start using the latest version as soon as possible.
Can anyone help?
Here's some code:-
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html, body { height: 100%; margin: 0; padding: 0; }
#map_canvas { height: 100%; }
</style>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=MY_KEY&v=3.23"> </script>
<script type="text/javascript">
var map;
function Initialize() {
try{
//google.maps.controlStyle = 'azteca';
map = new google.maps.Map(document.getElementById("map_canvas"), { zoom: 13, center: new google.maps.LatLng(51.41347, -0.83518), mapTypeId: google.maps.MapTypeId.ROADMAP });
return "";
} catch (err) {
return err.message;
}
}
</script>
</head>
<body>
<div id="map_canvas"></div>
</body>
</html>
If you uncomment the commented line all works fine (but with the old controls).
John
I'm pleased to say that I am now able to answer my own question!
This may be of use to the other poster (Mac21 was it) who was also having this same issue.
The vb.net WebBrowser control is the problem!
In the latest Frozen Release of the Google Maps API, they have stopped supporting IE8 (which is understandable!). The WebBrowser control, by default, uses IE7 for its rendering.
Fortunately, there is a way to over-ride this behaviour by adding a value into a key in the registry. Once this value is in place, the Google Maps API works a treat!
I can't claim any credit for the actual solution as I found it here https://weblog.west-wind.com/posts/2011/May/21/Web-Browser-Control-Specifying-the-IE-Version - so thanks to Rick Strahl!
Enjoy!
John

Google map in jquery mobile works when going directly to page but not when navigating from another page

I'm trying to get google maps to display on a jquery mobile page.
The map works fine if I type I go directly to the page in the browser. However, when I click a link on another jqm page that goes to the map page, I just get a blank grey screen. The markers are actually there but they are plotted off the viewable area above and to the left of the viewport. Also weird is that I am able to drag on the canvas and bring the markers into view in a small, invisible viewport in the upper left hand corner (probably about 100 px wide and 200 px high), but I can't see the actual map.
Here's a screenshot: https://www.dropbox.com/s/p8berda8dbf6kh4/Screenshot%202015-05-25%2014.24.15.png?dl=0
If I immediately refresh the page after the failed load, everything shows up fine. So I don't think this is an API issue.
And one other oddity. If I wait like 10 min, the map will load properly when I click on the link to view the map. But then the next time I try it fails to load. I have to wait several minutes.
My code is basically ripped right from the jquery mobile site. Here's the relevant code:
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="http://maps.google.com/maps/api/js?sensor=false&key=MY_KEY"></script>
<!-- JQM and other scripts loaded here -->
<script>
$( document ).on( "pagecreate", "#map", function() {
    var defaultLatLng = new google.maps.LatLng(34.0983425, -118.3267434); 
    drawMap(defaultLatLng);
function drawMap(latlng) {
  var myOptions = {
    zoom: 14,
center: latlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  };
 var map = new google.maps.Map(document.getElementById("map-canvas"), myOptions);
new google.maps.Marker({
 position: latlng,
    map: map,
    title: "lat",
});
new google.maps.Marker({
position: new google.maps.LatLng(43.150358,-74.768798),
map: map,
title: 'hello',
});
}
});
</script>
<style>
#map, #map-canvas { width: 100%; height: 100%; padding: 0; }
</style>
</head>
<body>
#calling page
<div data-role="page" data-dom-cache="true" id="doors" data-url="doors" tabindex="0" class="ui-page ui-page-theme-a ui-page-active" style="position: relative; min-height: 559px;">
<div role="main" class="ui-content" id="">
View map
</div>
</div>
#map page
<div data-role="page" id="map" data-url="map" style="position: relative;">
<div data-role="header" data-theme="a"><h1>Maps</h1></div><div role="main" class="ui-content" id="map-canvas">
</div>
</div>
</body>
</html>
Well, after hours of banging my head against a wall I finally got it working by changing from pagecreate to pageshow. Interestingly pageshow is deprecated in v. 1.4.5 and is supposed to be replaced by pagecontainershow but pagecontainershow does not work.
And as usual, I find the answer within minutes of posting the question.

Google Maps API v3 *broken* in Safari 6.0.2

I have a fairly straightforward Google Maps implementation running well in Chrome on a Mac. Yet - I am not working on the mobile implementation as well as cross-browser fixes, and have discovered that the map itself is not properly displaying / functioning, let alone the markers and infowindows that should be showing up. The native zoom tool never displays and I can't click anywhere on the map or drag it.
I've been googling and googling but not turning much up. Any hints or help would be much appreciated (while realizing this is not specifically a code question - yet).
I discovered the prob on my own app, but tested using Google's 'hello world' for the maps API, and it's exactly the same issue:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map-canvas { height: 100% }
</style>
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDSh0tsHL1DQBwI0-xfuQkUezonGxlt39k&sensor=false">
</script>
<script type="text/javascript">
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(-34.397, 150.644),
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map-canvas"),
mapOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map-canvas"/>
</body>
</html>
Your map doesn't have a completely defined size. You need to specify both the height and width, either as percent up to a parent element that has a size or specifically define the size of the div. If the size isn't defined it is zero.

Google Map Touch events on HP touch screen

I'm developing a web app for an HP Compaq L2105tm touch screen on a windows 7 box. When I bring up maps.google.com in Chrome the map works just fine with pinch zooming and other touch events you'd expect from a touch screen. However, when I use the following code to do a basic google map embed, the touch events do not work as expected. (Pinch zoom does not work.)
<!doctype html>
<html lang="en">
<head>
<style>
html, body, div#map {
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div id="map"></div>
<script src="http://maps.googleapis.com/maps/api/js?sensor=true"></script>
<script>
(function() {
var div = document.getElementById('map');
var lat = -36.5;
var lng = 150.5;
var options = {
center: new google.maps.LatLng( lat, lng ),
mapTypeId: google.maps.MapTypeId.ROADMAP,
zoom: 8
};
var map = new google.maps.Map( div, options );
})();
</script>
</body>
</html>
My question is why does maps.google.com work with pinch zoom and my map not work with pinch zoom in the exact same browser/touch environment?
UPDATE
This issue was handled in the bug
https://issuetracker.google.com/issues/35824421
and was solved in version 3.27 of Google Maps JavaScript API in December 2016.
I have the same problem and actually spoke with someone on the Google Maps Api team and they are aware of the issue. Unfortunately, there is no timetable for when it will be addressed. So I guess you can take solace in knowing that they know it is an issue.
Seems like the new api addresses this
https://developers.google.com/maps/documentation/javascript/basics#Mobile

Cannot embed Google Map

As of...today, it seems, Google Maps no longer has embed code!
Can someone point me in the right direction, or maybe offer up some old embed code I could try to embed into something useful?
Here is the article explaining how to embed a Google Map:
http://maps.google.com/help/maps/getmaps/quick.html
I think this has to do with the Google+ Social Network "thing" that appeared in the last few days.
Also, I have tried the instructions in the link above both logged into a Google Apps account and not logged in to any Google account.
I just tried the embed code and it seems to be working correctly for me. Did you change anything on your page recently? Here is what I tried.
<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0"
marginwidth="0" src="http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&
amp;q=Birmingham,+MI&aq=1&sll=37.0625,-95.677068&sspn=64.880423,107.138672&
amp;ie=UTF8&hq=&hnear=Birmingham,+Oakland,+Michigan&t=h&z=12&
amp;ll=42.546701,-83.211319&output=embed"></iframe><br /><small><a
href="http://maps.google.com/maps?f=q&source=embed&hl=en&geocode=&
amp;q=Birmingham,+MI&aq=1&sll=37.0625,-95.677068&sspn=64.880423,107.138672&
amp;ie=UTF8&hq=&hnear=Birmingham,+Oakland,+Michigan&t=h&z=12&
amp;ll=42.546701,-83.211319" style="color:#0000FF;text-align:left">View Larger Map</a></small>
Try disabling your Maps Labs in order to use map embedding. - reference
http://maps.google.com - the embed box is now back.
I guess it was a temporary glitch. I am pretty sure it was not on my side, I tried a few different machines and browsers.
Google maps has shifted settings link from bottom right to top left, left side of search bar
Here is the code to add Google Maps to your webpage. No API key needed.
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map-canvas { height: 100% }
</style>
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?&sensor=true">
</script>
<script type="text/javascript">
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(54.584063, -5.928343),
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map-canvas"),
mapOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>BLAAAAAAAAAAAAAAAAAAA</title>
<link rel="stylesheet" href="style.css">
<body>
<div id = "map-canvas"/>
</body>