Map Info Window onclick function not working in Android

377 views
Skip to first unread message

Karthi Ponnusamy

unread,
Sep 3, 2011, 3:26:18 AM9/3/11
to rhom...@googlegroups.com

I am using Google map V2  in my application(android). In my app I have used custom info window. When user click on the infowindow(using ExtInfoWindow method ) I have to call a JavaScript function.

Here everything works fine in my mobile except , the onClick fun

Here is my code sample....


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
   
<meta name="viewport" content="width=320; user-scalable=no" />
   
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
   
<title>More map</title>
 
<script src="/public/js/jquery.min.js" type="text/javascript"></script>
 
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAAPDUET0Qt7p2VcSk6JNU1sBSM5jMcmVqUpI7aqV44cW1cEECiThQYkcZUPRJn9vy_TWxWvuLoOfSFBw" type="text/javascript"></script>
   
<script src="/public/js/extinfowindow.js" type="text/javascript"></script>

 
<script type="text/javascript">
 
var lat;
 
var lon;
 
var heading;
 
var map;

   function redirect(id){
         alert
(id);
   
}

   function mapCalling()
   
{
   
try{
     
if (GBrowserIsCompatible()) {
       
function createMarker(point, Icon, html ) {
           
var marker = new GMarker(point, Icon);
             
GEvent.addListener(marker, "click", function(){
                marker
.openExtInfoWindow(
                   map
,
                   
"simple_example_window",
                   html
,
                   
{beakOffset: 30}
                 
);
             
});
           
return marker;
         
}

         map
= new GMap2(document.getElementById("map"));
         map
.addControl(new GLargeMapControl());
         map
.addControl(new GMapTypeControl());
         map
.setCenter(new GLatLng("13.060422", "80.249583"), 15);

         
var latArray = new Array("13.060422","13.053891","13.06042");
         
var longArray = new Array("80.249583","80.201454","80.24958");

         
//We can iterate more locations in map
         
for(var j = 0;j<latArray.length;j++)
         
{

                           
var cIcon = new GIcon();
                            cIcon
.image = '/public/images/icon1.png';
                            cIcon
.iconSize = new GSize(19,25);
                            cIcon
.shadowSize = new GSize(70, 50);
                            cIcon
.iconAnchor = new GPoint(6, 20);
                            cIcon
.infoWindowAnchor = new GPoint(5, 1);

                             
var contentString = '<div id="info'+j+'" onclick="redirect(this.id);" style="font-size:11px;border:1px solid green;">Dispensary Name '+j+'<br> <br>Sample text<br><div>';
                             
var point = new GLatLng(latArray[j],longArray[j]);
                             
var marker = createMarker(point,cIcon, contentString )
                             map
.addOverlay(marker);
         
}
       
return false;
     
}
   
}catch(e){alert(e);}
 
}
 
</script>
</head>
<body onload="mapCalling()" >

<div id="map" style="width:320px; height:360px"></div>

</body>
</html>



It is Works fine in Desktop browser, What is the problem or Is there any alternative way to do this

Here is my screenshot

Can any one please help me...



Alexey Tikhvinsky

unread,
Sep 3, 2011, 1:01:42 PM9/3/11
to rhom...@googlegroups.com
Hi.

Rhodes has native Google Map view to work with google maps. It strongly recommended to use this component.

-alexey


--
You received this message because you are subscribed to the Google Groups "rhomobile" group.
To post to this group, send email to rhom...@googlegroups.com.
To unsubscribe from this group, send email to rhomobile+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rhomobile?hl=en.

Dmitry Prohorov

unread,
Sep 3, 2011, 2:46:41 PM9/3/11
to rhomobile
Which version of Rhodes do you use? If it is 3.1 with jQueryMobile
support, then I recommend you read jqm documentation about click
handling support.
If it is pre-3.1 version of Rhodes, it uses jQTouch library. Which
isn't supported anymore.

Hope it helps, DmitryP

On Sep 3, 11:26 am, Karthi Ponnusamy <karthi....@gmail.com> wrote:
> I am using Google map V2  in my application(android). In my app I have used
> custom info window. When user click on the infowindow(using ExtInfoWindow
> method ) I have to call a JavaScript function.
> Here everything works fine in my mobile except , the onClick fun
>
> Here is my code sample....
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd">
> <html>
> <head>
>    <meta name="viewport" content="width=320; user-scalable=no" />
>    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
>    <title>More map</title>
>  <script src="/public/js/jquery.min.js" type="text/javascript"></script>
>  <script src="http://maps.google.com/maps?file=api&v=2&sensor=false&key..."
> Here is my screenshot<https://picasaweb.google.com/111035130900690009669/ScrapbookPhotos#56...>

Alexey Tikhvinsky

unread,
Sep 3, 2011, 3:58:23 PM9/3/11
to rhom...@googlegroups.com
I meant that JavaScript Google maps is not tested with rhodes since we have implemented native component.
But Rhodes native Google map view can handle just clicks on predefined pins(pin's call-out), not on any point at a map...

-alexey

Karthi Ponnusamy

unread,
Sep 5, 2011, 12:30:17 AM9/5/11
to rhom...@googlegroups.com
HI,

In my application I have to show some information while clicking the place marker in the Google map.

How can I do this? or Is there any alternative way to do this?

My rhodes Version is 3.0.2


Thanks
--
Thanks & Regards,
Karthi Ponnusamy


map_1.png

Karthi Ponnusamy

unread,
Sep 5, 2011, 11:57:25 PM9/5/11
to rhom...@googlegroups.com
HI Alexey,

Can you please give me a solution for Google Map Issue


In my application I have to show some information while clicking the place marker in the Google map.

How can I do this? or Is there any alternative way to do this?

My rhodes Version is 3.0.2


Thanks

map_1.png

Alexey Tikhvinsky

unread,
Sep 7, 2011, 4:38:34 PM9/7/11
to rhom...@googlegroups.com
http://docs.rhomobile.com/rhodes/device-caps#mapview

Try to use native Google map view with annotations. Annotation is some graphical balloon which is shown when user clicks a pin at map. In annotation u can define URL (which in particular may call rhodes controller). It seems that u need something like this.

To use this new feature at Android u need to work with master branch (not 3.1 gem).

-alexey
Reply all
Reply to author
Forward
0 new messages