Anyone who has used the Google map API should notice that the JS script in the example is normal in FF, opera,... (non-IE6 browsers). An error will be reported in IE6:
Object missing
The Wrong row number generally points to the row created by the gmap2 object.
There are two solutions:
1. Specify charset = UTF-8 in Meta. For the reason, refer to Google.
2. What if charset in the application is not UTF-8? The solution is as follows:
To use the map API on a website, we need to reference a JS file. Here we can try to add a charset attribute in the script attribute.
<Script... charset = "UTF-8"> </SCRIPT>
Below are some examples
The map key used is
Default example (an object is missing in IE)
- <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <HTML xmlns = "http://www.w3.org/1999/xhtml">
- <Head>
- <Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
- <SCRIPT src = "http://maps.google.com/maps? File = API & V = 2 & Key = ABQIAAAAy_92lh6L5xhcKXiWFze7ahSeyyn5-963h60-vJRKrf4xaRdBuBTmF2UsZnFk8o95hGt2T99GRoVPiA"
- Type = "text/JavaScript"> </SCRIPT>
- <Title> Google map demo </title>
- <SCRIPT type = "text/JavaScript">
- // <! [CDATA [
- VaR map = NULL;
- VaR geocoder = NULL;
- Function initialize (){
- If (gbrowseriscompatible ()){
- Map = new gmap2 (document. getelementbyid ("map_canvas "));
- Map. setcenter (New glatlng (37.5429, 121.3776), 13 );
- Geocoder = new gclientgeocoder ();
- }
- }
- Function showaddress (Address ){
- If (geocoder ){
- Geocoder. getlatlng (
- Address,
- Function (point ){
- If (! Point ){
- Alert (address + "not found ");
- } Else {
- Map. setcenter (point, 13 );
- VaR marker = new gmarker (point );
- Map. addoverlay (Marker );
- Marker. openinfowindowhtml (Address );
- }
- }
- );
- }
- }
- //]>
- </SCRIPT>
- </Head>
- <Body onload = "initialize ()" onUnload = "gunload ()">
- <Input type = "text" name = "Address" size = "50" value = "No. 28 xisheng Street, Yantai City, 1st Avenue" onblur = "showaddress (this. Value);"/>
- <Div id = "map_canvas" style = "width: 500px; Height: 300px"> </div>
- </Body>
- </Html>
Meta example:
- <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <HTML xmlns = "http://www.w3.org/1999/xhtml">
- <Head>
- <Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
- <SCRIPT src = "http://maps.google.com/maps? File = API & V = 2 & Key = ABQIAAAAy_92lh6L5xhcKXiWFze7ahSeyyn5-963h60-vJRKrf4xaRdBuBTmF2UsZnFk8o95hGt2T99GRoVPiA"
- Type = "text/JavaScript"> </SCRIPT>
- <Title> Google map demo </title>
- <SCRIPT type = "text/JavaScript">
- // <! [CDATA [
- VaR map = NULL;
- VaR geocoder = NULL;
- Function initialize (){
- If (gbrowseriscompatible ()){
- Map = new gmap2 (document. getelementbyid ("map_canvas "));
- Map. setcenter (New glatlng (37.5429, 121.3776), 13 );
- Geocoder = new gclientgeocoder ();
- }
- }
- Function showaddress (Address ){
- If (geocoder ){
- Geocoder. getlatlng (
- Address,
- Function (point ){
- If (! Point ){
- Alert (address + "not found ");
- } Else {
- Map. setcenter (point, 13 );
- VaR marker = new gmarker (point );
- Map. addoverlay (Marker );
- Marker. openinfowindowhtml (Address );
- }
- }
- );
- }
- }
- //]>
- </SCRIPT>
- </Head>
- <Body onload = "initialize ()" onUnload = "gunload ()">
- <Input type = "text" name = "Address" size = "50" value = "No. 28 xisheng Street, Yantai City, 1st Avenue" onblur = "showaddress (this. Value);"/>
- <Div id = "map_canvas" style = "width: 500px; Height: 300px"> </div>
- </Body>
- </Html>
Script Attribute charset example
- <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <HTML xmlns = "http://www.w3.org/1999/xhtml">
- <Head>
- <Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
- <SCRIPT src = "http://maps.google.com/maps? File = API & V = 2 & Key = ABQIAAAAy_92lh6L5xhcKXiWFze7ahSeyyn5-963h60-vJRKrf4xaRdBuBTmF2UsZnFk8o95hGt2T99GRoVPiA"
- Type = "text/JavaScript" charset = "UTF-8"> </SCRIPT>
- <Title> Google map demo </title>
- <SCRIPT type = "text/JavaScript">
- // <! [CDATA [
- VaR map = NULL;
- VaR geocoder = NULL;
- Function initialize (){
- If (gbrowseriscompatible ()){
- Map = new gmap2 (document. getelementbyid ("map_canvas "));
- Map. setcenter (New glatlng (37.5429, 121.3776), 13 );
- Geocoder = new gclientgeocoder ();
- }
- }
- Function showaddress (Address ){
- If (geocoder ){
- Geocoder. getlatlng (
- Address,
- Function (point ){
- If (! Point ){
- Alert (address + "not found ");
- } Else {
- Map. setcenter (point, 13 );
- VaR marker = new gmarker (point );
- Map. addoverlay (Marker );
- Marker. openinfowindowhtml (Address );
- }
- }
- );
- }
- }
- //]>
- </SCRIPT>
- </Head>
- <Body onload = "initialize ()" onUnload = "gunload ()">
- <Input type = "text" name = "Address" size = "50" value = "No. 28 xisheng Street, Yantai City, 1st Avenue" onblur = "showaddress (this. Value);"/>
- <Div id = "map_canvas" style = "width: 500px; Height: 300px"> </div>
- </Body>
- </Html>
The example on the small site is based on the charset attribute of the script:
Http://www.t6new.cn/feature/maptest.html