Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

MapView Marker Problem
Started by boscotwcheung Jun 21 2016 08:20 PM

2 replies to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

boscotwcheung

[GLOBAL: userInfoPane.html]
boscotwcheung
  • Contributor

  • 123 posts
  • Corona SDK

I am using the native.newMapView() api to show a map. And I am trying to add a marker into the map:

				local function addMarker()
				
					local function markerListener(event)
						alert("type: "..event.type..', markerId: '..event.markerId..', lat: '..event.latitude..', long: '..event.longitude)
					end				

					local markerOpt = 
					{ 
						title = "Displayed Title", 
						subtitle = "Subtitle text", 
						listener = markerListener,
						-- This will look in the resources directory for the image file
						imageFile =  "map_marker.png",
						-- Alternatively, this looks in the specified directory for the image file
						-- imageFile = { filename="someImage.png", baseDir=system.TemporaryDirectory }
					}				

					local result, errorMessage = myMap:addMarker( currX, currY, markerOpt)
					if ( result ) then
						alert( "Marker added" )
					else
						alert( errorMessage )
					end
				
				end
				timer.performWithDelay( 30000, addMarker )

The marker didn't show up at all. I tried to center the map using the same location but still can't see the market.

 

I am using corona SDK: 2016.2900 (2016.6.14) and I am testing it on Android device 5.1.1

 

 

I also tried on XCode Simulator. The map is not google map and has no marker as well.



[TOPIC: post.html]
#2

boscotwcheung

[GLOBAL: userInfoPane.html]
boscotwcheung
  • Contributor

  • 123 posts
  • Corona SDK

Sorry. I found a mistake. It is working now.



[TOPIC: post.html]
#3

psandimp

[GLOBAL: userInfoPane.html]
psandimp
  • Observer

  • 2 posts
  • Corona SDK

Hello! My problem is similar to yours. My marker appears only in a few times I call the map. Most of the time it does not appear.

I used a similar code.




[topic_controls]
[/topic_controls]