Dear All
I'm building a iPhone application that uses google maps in a UIWebView

I created a class that gets the iPhone screen touch events and
converts these to google maps javascript.
It works fine exept for one thing.

My map contains markers from a KML parsing through geoXml.
When I click on the iPhone display, I want to fire a map "click" event
to the map so :
- I can open an infowindow if the click was over a marker
- I can update the position of the center marker if the click was on
the map

Here is what I do :

1) I add a click listener to the map

GEvent.addListener(map, "click", function (overlay, latlng)
{ MapClickHandler(overlay, latlng); } );

2) I create the handler as follow :

function MapClickHandler(overlay, latlng)
{
        // the map has been clicked (not a marker)
        // if a marker was clicked (latlng would be null)
        if(latlng)
        {
                // update current lat/long
                Lat = latlng.y;
                Long = latlng.x;
                // Display new position marker
                UpdateCurrentPositionMarker();

                // the map has been moved
                zoom = map.getZoom();
                // reload the kml now
                reloadKml();
        }
}

3) when the iphone screen is clicked, I call this javascript :

The following javascript converts the pixel coordinates to latlng and
fires a click event to the map.

function iPhoneScreenClicked(pixX, pixY)
{
   var newCenterPixel = new GPoint(pixX, pixY);
   var newCenterLatLng = map.fromContainerPixelToLatLng
(newCenterPixel);
   // trigger an event to the map with a unknown overlay !
  GEvent.trigger(map, "click", undefined, newCenterLatLng);  <<<
PROBLEM HERE
}

Unfortunatelly this does not work since the parameter overlay is lost
as soon as I pass something as a parameter in the function.

I tried different ways, unfortunatelly never gets a working solution

GEvent.trigger(map, "click", , newCenterLatLng);  << WORKS BUT RESULTS
IN JS ERROR

GEvent.trigger(map, "click", '' , newCenterLatLng);  << OVERLAY IS
LOST

I was thinking about a function that could retrieve an overlay at a
given latlng so I can update my function to :

function iPhoneScreenClicked(pixX, pixY)
{
   var newCenterPixel = new GPoint(pixX, pixY);
   var newCenterLatLng = map.fromContainerPixelToLatLng
(newCenterPixel);
  GEvent.trigger(map, "click", map.getoverlay(newCenterLatLng),
newCenterLatLng);  <<< HOW TO DO THAT ?
}

Any help would be greatly appreciated, I'm stuck for 3 days on this !
thanks to all

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to