S stanks Active Member Licensed User Longtime User Dec 7, 2018 #1 Hi Following https://www.b4x.com/android/forum/threads/google-maps-with-fusedlocationprovider.83876/ tutorial, i tried to adapt it to my app. GPS settings dialog should be opened from activity "Test" and not Main only when user taps on button for showing location on map. If we have that lat/lon in DB show it on the map. If we don't have that lat/lon in DB, call FLP, get lat/lon and show it on the map. User can use all other stuff in app without that GPS and FLP. I don't have a problem with storing that values in DB, but logic with calling/showing GPS dialog to user and calling FLP. Where i put code which is in Main activity in sub Activity_Create? Should i change/adapt some other part of that code from that example or not? Thanks
Hi Following https://www.b4x.com/android/forum/threads/google-maps-with-fusedlocationprovider.83876/ tutorial, i tried to adapt it to my app. GPS settings dialog should be opened from activity "Test" and not Main only when user taps on button for showing location on map. If we have that lat/lon in DB show it on the map. If we don't have that lat/lon in DB, call FLP, get lat/lon and show it on the map. User can use all other stuff in app without that GPS and FLP. I don't have a problem with storing that values in DB, but logic with calling/showing GPS dialog to user and calling FLP. Where i put code which is in Main activity in sub Activity_Create? Should i change/adapt some other part of that code from that example or not? Thanks
Erel B4X founder Staff member Licensed User Longtime User Dec 9, 2018 #2 Not sure that I understand the question. These lines set the map location source: Code: Dim jo As JavaObject = gmap jo.RunMethod("setLocationSource", Array(Starter.LocationSource)) You can call it from wherever you like. Upvote 0
Not sure that I understand the question. These lines set the map location source: Code: Dim jo As JavaObject = gmap jo.RunMethod("setLocationSource", Array(Starter.LocationSource)) You can call it from wherever you like.
S stanks Active Member Licensed User Longtime User Dec 9, 2018 #3 well the prolem is that when i adapt (copy/paste) your example to my app, user has to enable GPS when app starts. but user can use my app without using GPS. GPS and FLP is necessary only when they want to see loc on map or when they want to get their current loc. so to avoid that starting GPS settings dialog from Main i have to put that code and start GPS settings dialog when user taps on button which will show loc on map and that is not Main activity. Upvote 0
well the prolem is that when i adapt (copy/paste) your example to my app, user has to enable GPS when app starts. but user can use my app without using GPS. GPS and FLP is necessary only when they want to see loc on map or when they want to get their current loc. so to avoid that starting GPS settings dialog from Main i have to put that code and start GPS settings dialog when user taps on button which will show loc on map and that is not Main activity.
S stanks Active Member Licensed User Longtime User Dec 9, 2018 #4 i partially solved this by adding one boolean variable in second activity and pass true to third when user taps button but i still have issues (read not working as i expected) Upvote 0
i partially solved this by adding one boolean variable in second activity and pass true to third when user taps button but i still have issues (read not working as i expected)
S stanks Active Member Licensed User Longtime User Dec 9, 2018 #5 hm i think i solved this. will check and test more so i can [SOLVED] this Upvote 0
peacemaker Expert Licensed User Longtime User Dec 9, 2018 #6 I fsoleved, please, do not forget to publish any result codes... Upvote 0
S stanks Active Member Licensed User Longtime User Dec 9, 2018 #7 Erel said: Not sure that I understand the question. These lines set the map location source: Code: Dim jo As JavaObject = gmap jo.RunMethod("setLocationSource", Array(Starter.LocationSource)) You can call it from wherever you like. Click to expand... How? object is gmap. i don't have gmap in every activity...it is in only one activity. so from 1st i should call FLP and get loc or take loc from DB and call second activity to show FLP or DB location. so how to call it from wherever? thanks Upvote 0
Erel said: Not sure that I understand the question. These lines set the map location source: Code: Dim jo As JavaObject = gmap jo.RunMethod("setLocationSource", Array(Starter.LocationSource)) You can call it from wherever you like. Click to expand... How? object is gmap. i don't have gmap in every activity...it is in only one activity. so from 1st i should call FLP and get loc or take loc from DB and call second activity to show FLP or DB location. so how to call it from wherever? thanks
S stanks Active Member Licensed User Longtime User Dec 9, 2018 #8 no i didn't solve this....i don't know how... Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Dec 10, 2018 #9 You can use CallSubDelayed to call a sub in the activity with the map and set the location source. Upvote 0
S stanks Active Member Licensed User Longtime User Dec 10, 2018 #11 if i leave that code in starter, when i start my app i get world map activity. this is not what i wanted. to be easier to understand, can you change your example and add one button on which when user tap it will open world map with that hardcoded location from your example and 2nd button when tapped will start FLP, get current location and show it on world map. this is what i am trying to achieve. thanks for reading Upvote 0
if i leave that code in starter, when i start my app i get world map activity. this is not what i wanted. to be easier to understand, can you change your example and add one button on which when user tap it will open world map with that hardcoded location from your example and 2nd button when tapped will start FLP, get current location and show it on world map. this is what i am trying to achieve. thanks for reading
Erel B4X founder Staff member Licensed User Longtime User Dec 10, 2018 #12 Why are you using FLP for this? Why not show a marker in the destination point? Upvote 0
S stanks Active Member Licensed User Longtime User Dec 10, 2018 #13 because it is faster? if i understand you second question it is because destination point doesn't have lat/lon when my app is started and because for some destination points i don't have full address meaning no address with number so i get point in the center of the address (street long 5km will have point in the middle of it and not on exact point what i want) Upvote 0
because it is faster? if i understand you second question it is because destination point doesn't have lat/lon when my app is started and because for some destination points i don't have full address meaning no address with number so i get point in the center of the address (street long 5km will have point in the middle of it and not on exact point what i want)
Erel B4X founder Staff member Licensed User Longtime User Dec 10, 2018 #14 Create a project based on my example and try to implement it. If you are unable to solve it then upload the project. Upvote 0
Create a project based on my example and try to implement it. If you are unable to solve it then upload the project.
S stanks Active Member Licensed User Longtime User Dec 10, 2018 #16 here it is. i tried but i don't know how to do it. i moved all code from starter to another service. if code stay in starter service every time i start app first map is showed and not main activity which now has 1 button. if user taps on that button service should be called, flp should get current loc and show it on map. if service does not work it should show 30,10 location marker. Attachments flp.zip flp.zip 11.5 KB · Views: 322 Upvote 0
here it is. i tried but i don't know how to do it. i moved all code from starter to another service. if code stay in starter service every time i start app first map is showed and not main activity which now has 1 button. if user taps on that button service should be called, flp should get current loc and show it on map. if service does not work it should show 30,10 location marker.
S stanks Active Member Licensed User Longtime User Dec 10, 2018 #17 ok. so here it is. working example (for now) with current location from FLP and hardcoded value (this value was not tested but i hope that it works ok too). i used FLP lib and not example from Erel. i simply don't know how to do that with his example. only thing you need to change is GEO API KEY and run test. Attachments flp.zip flp.zip 13 KB · Views: 350 Upvote 0
ok. so here it is. working example (for now) with current location from FLP and hardcoded value (this value was not tested but i hope that it works ok too). i used FLP lib and not example from Erel. i simply don't know how to do that with his example. only thing you need to change is GEO API KEY and run test.
Erel B4X founder Staff member Licensed User Longtime User Dec 10, 2018 #18 This is the correct approach if you just want to mark a specific point. Upvote 0
S stanks Active Member Licensed User Longtime User Dec 11, 2018 #19 is it possible to adapt your example to something like that? (less code and much more readable) Upvote 0