Hi,
I have integrated the Google map API using php and js. But while click
on the ICON, i am getting the infoWindow is not open up.
Also getting error in error console as "this.map is null". On each
click I want to open the info window. Please anybody help me.
I am attaching the code as well.
--------------------------------------------------------------------------------------------
<script>
GMap = function(id, address, label)
{
this.id = id;
this.address = address;
this.label = typeof label == "undefined" ? address : label;
this.geocoder = new GClientGeocoder();
}
GMap.prototype = {
id:'',
map:'',
geocoder:'',
address:'',
marker:'',
label:'',
show:function()
{
if (this.address.indexOf(" ") !== -1)
{
this.address.replace(/\s/, "+");
}
this.geocoder.getLatLng(
this.address,
function(point)
{
if (!point)
{
m.showDefaultMap();
}
else
{
m.showMap(point);
}
}
);
},
setAddress:function(address)
{
if (typeof address == "object")
{
var a = address;
this.address = a["address"]+", "+
a["city"]+
(typeof a["state"] ==
"undefined" ? "": ", "+a["state"])+
(typeof a["country"]
== "undefined" ? "" : ", "+a["country"])
+
(typeof a["zip"] ==
"undefined" ? "" : ", "+a["zip"]);
}
else
{
this.address = address;
}
},
setLabel:function(l)
{
this.label = l;
},
showDefaultMap:function()
{
if (typeof this.map != 'object')
{
this.map = new GMap2(document.getElementById(this.id));
this.map.addControl(new GHierarchicalMapTypeControl());
this.map.addControl(new GOverviewMapControl());
this.map.addControl(new GLargeMapControl3D());
}
this.map.setCenter(new GLatLng(GMAP_DEF_LAT,GMAP_DEF_LNG),
GMAP_DEF_ZOOM);
},
showMap:function(point)
{
var imageUrl="../../../images/web_map_pointer.png";
var hIcon = new GIcon();
hIcon.image = imageUrl;
hIcon.iconSize = new GSize(57,42);
hIcon.iconAnchor = new GPoint(25,25);
if (typeof this.map != 'object')
{
this.map = new GMap2(document.getElementById(this.id));
this.map.addControl(new GHierarchicalMapTypeControl());
this.map.addControl(new GOverviewMapControl());
this.map.addControl(new GLargeMapControl3D());
}
this.map.setCenter(point, 13);
if (typeof this.marker != "object")
{
this.marker = new GMarker(point,hIcon);
this.map.addOverlay(this.marker);
//this.marker.openInfoWindowHtml(this.label||this.address);
this.map.openInfoWindowHtml(point,this.label||
this.address);
GEvent.addListener(this.marker,'click',
function() {
this.map.openInfoWindowHtml(point,this.label||
this.address);
}
);
}
else
{
this.marker.setLatLng(point);
this.marker.openInfoWindowHtml(this.label||this.address);
}
}
};
</script>
-------------------------------------------------------------------
Also is there any way to show values in 'pin' icon dynamically?
--
You received this message because you are subscribed to the Google Groups
"Google Maps API V2" 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.