Add Marker to Google Maps with a tap or touch event?

Hi,

is this possible?

I tried this and it only zooms in when I tap:

local myMap = native.newMapView( 20, 20, 300, 220 ) myMap.anchorX = 0 myMap.anchorY = 0 local function onTap(event) myMap:addMarker( event.latitude, event.longitude, { title="Markter title", subtitle="Subtitle" } ) end local function p() myMap:addEventListener("tap", onTap) end local rect = display.newRect(250,350, 50,50) rect:addEventListener("tap", p)

It’s very time consuming to test as the map can’t be simulated in the simulator.

I added the “p” function to make sure that the map was loaded on the phone before I added the event. I tried it without the “p” function as well with the same results.

Best regards,

Tomas

Hi Tomas,

If you want to be notify when you touch a map, you must use the “mapLocation” event. For example based on you code

local function p(event)
    print(“lat”, event.latitude)
    print(“lon”, event.longitude)
end
myMap:addEventListener(“mapLocation”, p)

Thanks, just what I was looking for!

I have another question as well:

I would like to create a map without any names (no names what so ever), is this possible?

I found this page:

http://css.dzone.com/articles/google-maps-without-any

So it is possible but that guy is using Java and have access to all the methods in the Google Maps API.

According to the Corona Docs I don’t think this is possible:

http://docs.coronalabs.com/api/type/Map/index.html

But if there is a way I’d like to know.

Thanks and best regards,

Tomas

Maybe it might be easier to use a webView and load the map with all the preferred settings but not sure if the “mapLocation” listener would work then?

Best regards,

Tomas

Hi Tomas,

If you want to be notify when you touch a map, you must use the “mapLocation” event. For example based on you code

local function p(event)
    print(“lat”, event.latitude)
    print(“lon”, event.longitude)
end
myMap:addEventListener(“mapLocation”, p)

Thanks, just what I was looking for!

I have another question as well:

I would like to create a map without any names (no names what so ever), is this possible?

I found this page:

http://css.dzone.com/articles/google-maps-without-any

So it is possible but that guy is using Java and have access to all the methods in the Google Maps API.

According to the Corona Docs I don’t think this is possible:

http://docs.coronalabs.com/api/type/Map/index.html

But if there is a way I’d like to know.

Thanks and best regards,

Tomas

Maybe it might be easier to use a webView and load the map with all the preferred settings but not sure if the “mapLocation” listener would work then?

Best regards,

Tomas