Map widget problem(s)

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
russel18
Posts: 3
Joined: Wed Sep 23, 2020 10:53 pm

Map widget problem(s)

Post by russel18 » Wed Sep 23, 2020 11:13 pm

Hello fellow LiveCoders,

I have a problem implementing a map widget for my Android app.
I want to display markers but I just can't get them to show up on the map.
I use the example code provided in the Dictionary.
See my code here:

Code: Select all

 
 on openCard
  local tMarkers, tMarkerData
   set the region of widget "Map" to "55 .9533,-3 .1883, 10, 10"
   set the centerCoordinates of widget "Map" to "55 .9533,-3 .1883"
   put "55 .9533,-3 .1883" into tMarkerData["coordinates"]
   put "Centre of Edinburgh" into tMarkerData["title"]
   put tMarkerData into tMarkers["Edinburgh"]
   set the markers of widget "Map" to tMarkers
   end openCard
I use the spaces inside the coordinates because otherwise the forums wouldn't let me post it, thinking they're external URLs. In my code, the spaces are not there.
As you can see, I'm doing it exactly like in the Dictionary example but neither the marker is shown nor is the map centered at the coordinates that I'm submitting.
I just don't see my mistake here, hope that anyone can help me.

Since the map widget is not opening on an emulator for me, for whatever reason,
I test my application by saving it as standalone and then moving it to my phone.
The map is shown there, but like I said, with no markers and wrongly centered.

What am I missing here?

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: Map widget problem(s)

Post by bn » Thu Sep 24, 2020 12:56 am

Hello Russel,

Welcome to the forum.

The map widget did not like the spaces in your coordinates, it did not accept it as numbers.
More precisely the spaces in the coordinates. The dictionary example is correct.
This works for me in LC 9.6.1

Code: Select all

on mouseUp
   local tMarkers, tMarkerData
   set the region of widget "Map" to "55.9533,-3.1883,10,10"
   set the centerCoordinates of widget "Map" to "55.9533,-3.1883"
   put "55.9533,-3.1883" into tMarkerData["coordinates"]
   put "Centre of Edinburgh" into tMarkerData["title"]
   put tMarkerData into tMarkers["Edinburgh"]
   set the markers of widget "Map" to tMarkers
end MouseUp


Please note that polylines stopped working for the map widget starting version LC 9.0.4

https://quality.livecode.com/show_bug.cgi?id=22377

Kind regards
Bernd

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Map widget problem(s)

Post by richmond62 » Thu Sep 24, 2020 8:52 am

Please note that polylines stopped working for the map widget starting version LC 9.0.4
We will update you when the status of this report changes.
A year later and still waiting . . . come on.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7391
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Map widget problem(s)

Post by jacque » Thu Sep 24, 2020 5:39 pm

@Bernd, he said he added the spaces due to forum restrictions on new users.

Maybe an inclusion is missing?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: Map widget problem(s)

Post by bn » Thu Sep 24, 2020 6:13 pm

jacque wrote:
Thu Sep 24, 2020 5:39 pm
@Bernd, he said he added the spaces due to forum restrictions on new users.
Maybe an inclusion is missing?
Oh, I missed that he intentionally added the spaces. I can not think of any inclusion that would be needed since the widget does show on his phone but probably with the default coordinates.
I have no idea why it does not work then.

Kind regards
Bernd

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7391
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Map widget problem(s)

Post by jacque » Thu Sep 24, 2020 7:17 pm

Did you include internet in the app? There is an internet permission in the Android pane in standalone settings, as well as in the inclusions. If you do see a map at all then I'd assume you already have those but double check.

Otherwise I can't imagine what might be wrong.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

russel18
Posts: 3
Joined: Wed Sep 23, 2020 10:53 pm

Re: Map widget problem(s)

Post by russel18 » Mon Sep 28, 2020 11:44 am

Hello all,

thank you for your replies.

I got it working by adding a button setting up the markers.
As you can see in my previous code, it was inside the openCard command because I wanted to markers to be shown on opening the card. I don't know why, but it didn't work for me. After adding the button und putting said script inside the mouseUp command, the markers show up correctly. Not exactly my wanted solution but I'm fine with it.

Thank you all

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: Map widget problem(s)

Post by bn » Mon Sep 28, 2020 11:53 am

russel18 wrote:
Mon Sep 28, 2020 11:44 am
I got it working by adding a button setting up the markers.
As you can see in my previous code, it was inside the openCard command because I wanted to markers to be shown on opening the card. I don't know why, but it didn't work for me. After adding the button und putting said script inside the mouseUp command, the markers show up correctly. Not exactly my wanted solution but I'm fine with it.
I tested your code in an openCard handler in the IDE and it worked. Maybe some other things in the openCard handler prevents it from working.

You could also try

Code: Select all

on openCard
   -- other code here
   send "doMap" to me  in 20 milliseconds
end openCard

on doMap
   -- your code to set  the map
end doMap

This will give the system a bit of time to do openCard and when it is finished it will set the map.

Maybe that works.

Kind regards
Bernd

Post Reply