dapriett / nativescript-google-maps-sdk

Cross Platform Google Maps SDK for Nativescript
MIT License
244 stars 164 forks source link

feat(all): add IndoorLevelActivated and IndoorBuildingFocused #387

Closed RignonNoel closed 4 years ago

RignonNoel commented 4 years ago

Did


External ressources

Android Model:

Android Listener:

IOS Model:

IOS Listener:

nickolanack commented 4 years ago

Nice!! Have you started an iOS implementation?

RignonNoel commented 4 years ago

@nickolanack Yes, just finished i think, my PR is updated! ;)

RignonNoel commented 4 years ago

@dapriett @nickolanack

If you have some input i've problem running the demo test in local with tns run android

It could be better if i can run the demo to validate and finish this PR ;p

ERROR in ./main-page.js
Module not found: Error: Can't resolve 'nativescript-google-maps-sdk' in '/home/fjnr/WebstormProjects/nativescript-google-maps-sdk/demo/app'
 @ ./main-page.js 3:17-56
 @ ./bundle-config.js
 @ ./app.js

ERROR in ./main-page.xml
Module not found: Error: Can't resolve 'nativescript-google-maps-sdk' in '/home/fjnr/WebstormProjects/nativescript-google-maps-sdk/demo/app'
 @ ./main-page.xml 1:74-113 1:200-239 1:318-357 1:444-483 1:562-601 1:707-746 1:825-864 1:970-1009 1:1088-1127 1:1234-1273 1:1352-1391 1:1498-1537
 @ . sync (?<!\bApp_Resources\b.*)\.(xml|css|js|(?<!\.d\.)ts|(?<!\b_[\w-]*\.)scss)$
 @ ./app.js

Webpack compilation complete. Watching for file changes.
Webpack build done!
Project successfully prepared (android)
File change detected. Starting incremental webpack compilation...
Successfully transferred runtime.js on device emulator-5554.
Restarting application on device emulator-5554...
Webpack compilation complete. Watching for file changes.
Webpack build done!
File change detected. Starting incremental webpack compilation...
JS: HMR: Hot Module Replacement Enabled. Waiting for signal.
Webpack compilation complete. Watching for file changes.
Webpack build done!
System.err: An uncaught Exception occurred on "main" thread.
System.err: Unable to start activity ComponentInfo{org.nativescript.demo/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Calling js method onCreate failed
System.err: Error: Cannot find module 'nativescript-google-maps-sdk'
System.err: 
System.err: StackTrace:
System.err: java.lang.RuntimeException: Unable to start activity ComponentInfo{org.nativescript.demo/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Calling js method onCreate failed
System.err: Error: Cannot find module 'nativescript-google-maps-sdk'
System.err:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
System.err:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
System.err:     at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
System.err:     at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
System.err:     at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
System.err:     at android.os.Handler.dispatchMessage(Handler.java:106)
System.err:     at android.os.Looper.loop(Looper.java:193)
System.err:     at android.app.ActivityThread.main(ActivityThread.java:6669)
System.err:     at java.lang.reflect.Method.invoke(Native Method)
System.err:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
System.err: Caused by: com.tns.NativeScriptException: Calling js method onCreate failed
System.err: Error: Cannot find module 'nativescript-google-maps-sdk'
System.err:     at com.tns.Runtime.callJSMethodNative(Native Method)
System.err:     at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1242)
System.err:     at com.tns.Runtime.callJSMethodImpl(Runtime.java:1122)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1109)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1089)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1081)
System.err:     at com.tns.NativeScriptActivity.onCreate(NativeScriptActivity.java:19)
System.err:     at android.app.Activity.performCreate(Activity.java:7136)
System.err:     at android.app.Activity.performCreate(Activity.java:7127)
System.err:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
System.err:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
System.err:     ... 11 more
Successfully synced application org.nativescript.demo on device emulator-5554.

Here is the process i followed (My android studio emulator is already launched):

cd demo/
npm install
tns run android

If you could help me on this i will update the documentation to explain how to contribute on the project after.

nickolanack commented 4 years ago
cd ../src/
npm run build
#  npm run plugin.link 
cd ../demo
tns debug android
RignonNoel commented 4 years ago

Thanks a lot @nickolanack !

I've been able to test it and change a lot of things for compatibility between iOS and Android.

I've a first base that can return something like this:

JS: Building focus changed: {"defaultLevelIndex":2,"levels":[],"isUnderground":false}

Unfortunatly i have a problem with levels since i don't find a way to correctly work with the differente implementation of Array (nsArray, Java array and JS array). I've updated my PR with my current best solution, but i will try to continue tomorrow morning.

If you have some input on this type of problem feel free, it should be the last thing to finish this PR

nickolanack commented 4 years ago

for android (java.util.List) use:

...getLevels().size() 
...getLevels().get(count)

😉

nickolanack commented 4 years ago

oh, I think IOS needs to have this.nativeView.indoorDisplay.delegate set to a IndoorDisplayDelegateImpl.initWithOwner(new WeakRef(this)) somewhere

works perfectly for me after that.!👍

RignonNoel commented 4 years ago

oh, I think IOS needs to have this.nativeView.indoorDisplay.delegate set to a IndoorDisplayDelegateImpl.initWithOwner(new WeakRef(this)) somewhere

works perfectly for me after that.!+1

Yes, you right! I based my work on the existing MapViewDelegateImpl but in my case i've no IndoorDisplay or IndoorDisplayBase in the base code and i don't see exactly how it need to turn out for the moment.

I think that we need to create these classes, but i don't see how and i've no iOS to test it :/

RignonNoel commented 4 years ago

@nickolanack It seems that we never get the final onIndoorLevelActivated. I tried it with multiple building in Montreal and i just got the onIndoorBuildingFocused.

nickolanack commented 4 years ago

@RignonNoel i PR'd (into feature-new_events of your fork ) the corrected ios delegate instantiation, and fixed level selection event. 🙀 I was wondering what would happen/(if it was possible) to pr into an already open pr... https://github.com/RignonNoel/nativescript-google-maps-sdk/pull/1

RignonNoel commented 4 years ago

@nickolanack Wow! You're the man! Thanks a lot for the iOS side.

And thanks a lot more again for the android quick fix, seems that i was not able to read my own stupid error :stuck_out_tongue_closed_eyes:

nickolanack commented 4 years ago

np👍

RignonNoel commented 4 years ago

Tested on my side for Android, seems ready to merged @dapriett if you're ok