Closed hirbod closed 10 years ago
@Hirbod , The test branch should work on Android 4.1.2 (I confirmed with Android 4.1, today).
Do you use "com.google.playservices" version 19.0.0?
$> cordova plugin list
android.support.v4 1.0.0 "Android Support v4"
com.google.playservices 19.0.0 "Google Play Services for Android"
com.googlemaps.ios 1.8.1 "Google Map iOS SDK for Cordova"
plugin.google.maps 1.2.1 "phonegap-googlemaps-plugin"
plugin.http.request 1.0.0 "phonegap-http-request"
android.support.v4 1.0.0 "Android Support v4" com.ccsoft.plugin.CordovaFacebook 1.0.3 "CordovaFacebook" com.google.playservices 19.0.0 "Google Play Services for Android" com.googlemaps.ios 1.8.1 "Google Map iOS SDK for Cordova" com.phonegap.plugins.PushPlugin 2.3.1 "PushPlugin" com.phonegap.plugins.barcodescanner 1.2.0 "BarcodeScanner" de.appplant.cordova.plugin.email-composer 0.8.1 "EmailComposer" hu.dpal.phonegap.plugins.SpinnerDialog 0.3.0 "SpinnerDialog" nl.x-services.plugins.socialsharing 4.3.4 "SocialSharing" org.apache.cordova.console 0.2.10 "Console" org.apache.cordova.device 0.2.11 "Device" org.apache.cordova.dialogs 0.2.9 "Notification" org.apache.cordova.file 1.3.0 "File" org.apache.cordova.geolocation 0.3.8 "Geolocation" org.apache.cordova.inappbrowser 0.5.2 "InAppBrowser" org.apache.cordova.media 0.2.12 "Media" org.apache.cordova.network-information 0.2.11 "Network Information" org.apache.cordova.statusbar 0.1.8 "StatusBar" plugin.google.maps 1.2.1 "phonegap-googlemaps-plugin" plugin.http.request 1.0.0 "phonegap-http-request"
When you look at Pastebin, there is something I'm not sure about:
D/CordovaLog( 5893): file:///android_asset/www/index.html: Line 95 : Uncaught TypeError: Object #
Don't know where this error happen, maybe this cause the bug, but I dont know.. Version 1.1.5 seems to work nearly fine (except of few problems, maybe there are code related)
Finally, after hours of debugging:
$rootScope.map.one(plugin.google.maps.event.MAP_READY, $scope.onMapInit);
don't work with 1.2+! Before it was fine. After updating, it only fires and stop throwing errors with () on the function
$rootScope.map.one(plugin.google.maps.event.MAP_READY, $scope.onMapInit());
The first example works on iOS. Android only till 1.1.5 I really don't know what happened there... just spend like 7 hours finding something like this...
And there is something else. Reverse Geocoding on Android does not deliver "lines". The address is totally different ordered in the json result. Maybe it depends on what each Geolocator deliver, but it should be standarized.
Android has much more Data, like:
locale de_DE country as ISO-Code extracted house number
but also missing the completly formatted address line. Could you make this more equal in your result return trough js? Now I have to write exceptions for each plattform to prevent errors in accessing object nodes they don't exist
$rootScope.map.one(plugin.google.maps.event.MAP_READY, $scope.onMapInit());
This is wrong code. The above code means like this:
var retValue = $scope.onMapInit(); // Maybe undefined
document.addEventListener("map_ready", retValue);
And I confirmed the test branch worked on Android 4.1 (even on Android 2.3) In order to detect what wrong is, try this simple code:
document.addEventListener('deviceready', function() {
var map_div = document.getElementById("map_canvas");
var map = plugin.google.maps.Map.getMap(map_div);
map.on(plugin.google.maps.event.MAP_READY, function() {
alert("MAP_READY");
});
});
Regarding of Geocode result, the plugin uses different Geocoder on Android and iOS.
Thus, the results are also different.
The lines
fields are in the extra
field in the response.
Extra is the extra information, not common fields.
I apologize that this explain is not written in the wiki page. The common fields are:
position
locality
adminArea
subAdminArea
(always empty in iOS)country
locale
(always empty in iOS)postalCode
subLocality
thoroughfare
subThoroughfare
(always empty in iOS)
Please read how did I write the code:
(Android)
https://github.com/wf9a5m75/phonegap-googlemaps-plugin/blob/master/src/android/plugin/google/maps/PluginGeocoder.java#L79
(iOS)
https://github.com/wf9a5m75/phonegap-googlemaps-plugin/blob/master/src/ios/GoogleMaps/Geocoder.m#L116
If you send me a better pull request to standardize, I will test and consider it.
I tried this:
$rootScope.map.one(plugin.google.maps.event.MAP_READY, function(){
alert('test');
});
My alert does not call. This have to be a bug.
Really, only if I use "$scope.onMapInit()" it will work. This makes absolutley no sense, as of version 1.1.5 it worked... mit "$scope.onMapInit" without ()
By the way: Android does not deliver the extra fields
Again,
I tried
var map_div = document.getElementById("map_canvas");
var map = plugin.google.maps.Map.getMap(map_div);
map.on(plugin.google.maps.event.MAP_READY, function() {
alert("MAP_READY");
});
And it does not work on my phone. I even updated right now to Android 4.3.1 using Cynagenmod, but there is the same problem. I guess its not OS related, it's a problem with the plugin. The same codebase worked before on 1.1.5, please believe me..
navigator.geolocation.getCurrentPosition($scope.onSuccess, $scope.onError, {enableHighAccuracy:true});
This works fine, even without (). But I found someone in a forum doing the same on his device like me. ( using () ) to call.
Ah, you use Cyangenmod. It might be the lost piece. Can you see the map currently, or not?
I just installed Cyangenmod right now because I wanted to try newer Android. Before, it was Stock 4.1.3 rooted.
Now its Cyangenmod 4.3.1
And I tried on stock Samsung Galaxy S4 with 4.4.4 (Phone of my friend) and the bug still occurs. Nontheless, it works now with () in function name. Without it won't work. I don't know how it is possible but this dirty workaround seems to run!
I see. I don't have enough time to test on Cyangenmod, let me pending this issue for a while.
Again: it does NOT depend on Cyangenmod... same on stock OS
Even though, I can not reproduce this issue on my devices.
Ok. Nevermind. It works now with $scope.onMapInit() - and thats fine
Finally I could reproduce this issue on an Android 4.1 with Cordova 3.6.3-0.2.13 and the test branch.
The strange thing is callbackContext.success();
in the getMap() does not invoke the JavaScript callback.
I'm checking now.
@Hirbod , I found out what's wrong, and fixed it. Thank you for your information.
Yihaaaaaaaa !!! I told you ! :D
You are right. Thank you :100:
I will try right now!
Confirmed! It works, bug is fixed!
Hi Masashi,
seems like v1.2 and your testbranch break on my Android. Nothing seems to work anymore. The map gets inited, but no MAP_READY callback fired, it even breaks
navigator.geolocation.getCurrentPosition($scope.onSuccess, $scope.onError, {enableHighAccuracy:true});
I can see some errors in logcat, but I can't understand them really. Please have a look.
Galaxy Note 1 (GT-N7000, Android 4.1.2)
LogCat: http://pastebin.com/iR168pLY
Version 1.1.5 works, #test don't. :cry: