Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

destroy map object #169

Closed
ammubasha opened this issue Aug 11, 2014 · 28 comments
Closed

destroy map object #169

ammubasha opened this issue Aug 11, 2014 · 28 comments
Milestone

Comments

@ammubasha
Copy link

i presumed map is cached in phone memory... is this a way to destroy the map completely at certain event say logout event of my application

@wf9a5m75
Copy link
Member

There is no way currently.
But map.clear() removes all objects and event listeners.

@ammubasha
Copy link
Author

Ok thanks....does map keep its data in cache or localstorage... will try to remove from there

@wf9a5m75
Copy link
Member

What data do you want to remove?
This plugin does not use local storage or cache.

@ammubasha
Copy link
Author

oh ok...i looking for a way to remove loaded map when my app is logged out

On Tue, Aug 12, 2014 at 9:55 PM, Masashi Katsumata <notifications@github.com

wrote:

What data do you want to remove?
This plugin does not use local storage or cache.


Reply to this email directly or view it on GitHub
#169 (comment)
.

@wf9a5m75
Copy link
Member

How about this way: map.clear() then map.setDiv(nulll)?

@ammubasha
Copy link
Author

yes i used it to destroy the map's child and div what i feel is the second
time map is not loading freshly even though i load it in the code
explicitly and it is coming from cache that time. sometime when my
application was open and move with my phone in the new place it shows new
marker(locate your curr location) with the old one ...

On Wed, Aug 13, 2014 at 9:34 PM, Masashi Katsumata <notifications@github.com

wrote:

How about this way: map.clear() then map.setDiv(nulll)?


Reply to this email directly or view it on GitHub
#169 (comment)
.

@wf9a5m75
Copy link
Member

So the problem is that current your location is old when you open the map second time?
Do you use map.getMyLocation() currently?

@ammubasha
Copy link
Author

Yes i used it.... even if move a bit away from the location with the
application open and reload the page it shows two markers some times

On Wed, Aug 13, 2014 at 10:53 PM, Masashi Katsumata <
notifications@github.com> wrote:

So the problem is that current your location is old when you open the map
second time?
Do you use map.getMyLocation() currently?


Reply to this email directly or view it on GitHub
#169 (comment)
.

@wf9a5m75
Copy link
Member

map.getMyLocation() uses LocationClient.getLastLocation() internally due to save the battery.
It means it returns old location sometimes.
So if you want to get real current location, please use other ways currently.
See #96

@ammubasha
Copy link
Author

Thank you.will try the same.
I got one more issue in ios(ver 7).i am using location marker. on click of
marker i show the popup(canvas).
if i click those markers repeatedly the application get crashed...this
happens only in IOS and clicking on marker. seems at this moment the map
object destroyed completely . any suggestions?

On Wed, Aug 13, 2014 at 11:55 PM, Masashi Katsumata <
notifications@github.com> wrote:

map.getMyLocation() uses LocationClient.getLastLocation() internally due
to save the battery.
It means it returns old location sometimes.
So if you want to get real current location, please use other ways
currently.
See #96 #96


Reply to this email directly or view it on GitHub
#169 (comment)
.

@wf9a5m75
Copy link
Member

Could you give me some code for test?

@wf9a5m75 wf9a5m75 modified the milestones: v1.2, v1.1.5 Aug 23, 2014
@wf9a5m75
Copy link
Member

I added map.remove() method which destroys the map object completely.
In order to use this method, you need to update the plugin.

$> cordova plugin rm plugin.google.maps
$> cordova plugin add plugin.google.maps --variable API_KEY_FOR_ANDROID= ... --variable API_KEY_FOR_IOS=...

@ammubasha
Copy link
Author

cool. will try thank you

On Fri, Aug 29, 2014 at 10:28 PM, Masashi Katsumata <
notifications@github.com> wrote:

Closed #169
#169.


Reply to this email directly or view it on GitHub
#169 (comment)
.

@OSFalcon0928
Copy link

So i attempted the map.remove() on my object and it is not removing the map at all. Is there another key piece that i am missing in order to complete this?

@wf9a5m75
Copy link
Member

@OSFalcon0928 What the plugin version do you use?, And what the os do you use, Android version or iOS version?

@OSFalcon0928
Copy link

I am currently using the one that is on the https://github.com/wf9a5m75/phonegap-googlemaps-plugin website under the download zip. This is for the Android Version.

@wf9a5m75
Copy link
Member

Is there any error messages in Logcat

@OSFalcon0928
Copy link

yeah. the one that stands out to me is this one:

W/System.err(22921): java.lang.IllegalArgumentException: remove is not a constant in plugin.google.maps.GoogleMaps$METHODS
W/System.err(22921): at java.lang.Enum.valueOf(Enum.java:198)
W/System.err(22921): at plugin.google.maps.GoogleMaps$METHODS.valueOf(GoogleMaps.java:95)
W/System.err(22921): at plugin.google.maps.GoogleMaps$1.run(GoogleMaps.java:151)
W/System.err(22921): at android.os.Handler.handleCallback(Handler.java:733)
W/System.err(22921): at android.os.Handler.dispatchMessage(Handler.java:95)
W/System.err(22921): at android.os.Looper.loop(Looper.java:157)
W/System.err(22921): at android.app.ActivityThread.main(ActivityThread.java:5356)
W/System.err(22921): at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err(22921): at java.lang.reflect.Method.invoke(Method.java:515)
W/System.err(22921): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
W/System.err(22921): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
W/System.err(22921): at dalvik.system.NativeStart.main(Native Method)
W/qdhwcomposer( 284): Excessive delay reading vsync: took 6133 ms

And the way i am calling it is newmap.vm.Map.remove();

@wf9a5m75
Copy link
Member

I can't understand your code.
newmap.vm.Map.remove();

map.remove() is not Map.remove()
On Sep 11, 2014 7:21 AM, "OSFalcon0928" notifications@github.com wrote:

yeah. the one that stands out to me is this one:

W/System.err(22921): java.lang.IllegalArgumentException: remove is not a
constant in plugin.google.maps.GoogleMaps$METHODS
W/System.err(22921): at java.lang.Enum.valueOf(Enum.java:198)
W/System.err(22921): at
plugin.google.maps.GoogleMaps$METHODS.valueOf(GoogleMaps.java:95)
W/System.err(22921): at
plugin.google.maps.GoogleMaps$1.run(GoogleMaps.java:151)
W/System.err(22921): at android.os.Handler.handleCallback(Handler.java:733)
W/System.err(22921): at android.os.Handler.dispatchMessage(Handler.java:95)
W/System.err(22921): at android.os.Looper.loop(Looper.java:157)
W/System.err(22921): at
android.app.ActivityThread.main(ActivityThread.java:5356)
W/System.err(22921): at java.lang.reflect.Method.invokeNative(Native
Method)
W/System.err(22921): at java.lang.reflect.Method.invoke(Method.java:515)
W/System.err(22921): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
W/System.err(22921): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
W/System.err(22921): at dalvik.system.NativeStart.main(Native Method)
W/qdhwcomposer( 284): Excessive delay reading vsync: took 6133 ms

And the way i am calling it is newmap.vm.Map.remove();


Reply to this email directly or view it on GitHub
#169 (comment)
.

@wf9a5m75
Copy link
Member

Can you share me the code how you do create the map?
On Sep 11, 2014 7:26 AM, "Masashi.K" wf9a5m75@gmail.com wrote:

I can't understand your code.
newmap.vm.Map.remove();

map.remove() is not Map.remove()
On Sep 11, 2014 7:21 AM, "OSFalcon0928" notifications@github.com wrote:

yeah. the one that stands out to me is this one:

W/System.err(22921): java.lang.IllegalArgumentException: remove is not a
constant in plugin.google.maps.GoogleMaps$METHODS
W/System.err(22921): at java.lang.Enum.valueOf(Enum.java:198)
W/System.err(22921): at
plugin.google.maps.GoogleMaps$METHODS.valueOf(GoogleMaps.java:95)
W/System.err(22921): at
plugin.google.maps.GoogleMaps$1.run(GoogleMaps.java:151)
W/System.err(22921): at
android.os.Handler.handleCallback(Handler.java:733)
W/System.err(22921): at
android.os.Handler.dispatchMessage(Handler.java:95)
W/System.err(22921): at android.os.Looper.loop(Looper.java:157)
W/System.err(22921): at
android.app.ActivityThread.main(ActivityThread.java:5356)
W/System.err(22921): at java.lang.reflect.Method.invokeNative(Native
Method)
W/System.err(22921): at java.lang.reflect.Method.invoke(Method.java:515)
W/System.err(22921): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
W/System.err(22921): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
W/System.err(22921): at dalvik.system.NativeStart.main(Native Method)
W/qdhwcomposer( 284): Excessive delay reading vsync: took 6133 ms

And the way i am calling it is newmap.vm.Map.remove();


Reply to this email directly or view it on GitHub
#169 (comment)
.

@OSFalcon0928
Copy link

sure. here is the snippet on creating the map:

if (mapPosition) {

            mapOptions['camera'] = {
                'latLng': new plugin.google.maps.LatLng(mapPosition.target.lat, mapPosition.target.lng),
                'tilt': mapPosition.tilt,
                'zoom': mapPosition.zoom,
                'bearing': mapPosition.bearing
            }
        }

        newMapVM.Map = plugin.google.maps.Map.getMap(mapOptions);

essentially i am creating a view model and storing the Map object created in the plugin into an object called .Map in my viewmodel. This in turn loads the map onto the screen by using:

newmapVM.Map.setDiv(newmapVM.mapDiv);

@wf9a5m75
Copy link
Member

I wonder how did you install the plugin. Because the error line number does not match with the current code.
For example,

The error log says:
There is METHODS.valueOf() at line 95 in GoogleMaps.java

at plugin.google.maps.GoogleMaps$METHODS.valueOf(**GoogleMaps.java:95**)

However METHODS.valueOf() is at line 189
https://github.com/wf9a5m75/phonegap-googlemaps-plugin/blob/master/src/android/plugin/google/maps/GoogleMaps.java#L189

Do you use old version?

@OSFalcon0928
Copy link

well i thought i got the latest version but perhaps i did not? I got the zip from the main site. I cannot seem to get $> cordova plugin rm plugin.google.maps
$> cordova plugin add plugin.google.maps --variable API_KEY_FOR_ANDROID= ... --variable API_KEY_FOR_IOS=...

to run for me

Is there a way i can ensure the correct plugin is installed?

@wf9a5m75
Copy link
Member

Ok, could you confirm the plugin.xml file at line 2?
You can find the version, like below.

<?xml version='1.0' encoding='utf-8'?>
<plugin id="plugin.google.maps" version="1.1.5"

@OSFalcon0928
Copy link

yup. 1.1.4 is what it says

@wf9a5m75
Copy link
Member

Ok. Now I understand.
The remove method of v1.1.4 occurs the error, because of bug.
The problem was fixed in v1.1.5.

4b04914

Thus, use v1.1.5.

By the way, I'm planing to release the new version: v1.2.0 in couple of days.
It's better than v1.2.0.
Stay tuned for future update on the official community.

@OSFalcon0928
Copy link

ok. so i am using this through vs 2013 and i cannot get the cordova download tool to work. Is there a good guide to installing it through vs?

@wf9a5m75
Copy link
Member

I'm sorry, but I'm not familiar with visual studio.
(Even I haven't knew you can install the plugin through visual studio)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants