Korzystam z mapy google z funkcją pokazywania i ukrywania i mam taki kod .xml w którym są lokalizację:
  1. <markers>
  2. <marker name="Claremont Theatre Club" address="Burwood Dr, Blackpool, Lancashire, FY3 8NS" lng="-3.049690" lat="53.829649" category="theatre" />
  3. <marker name="Pendle Productions" address="249 Hawes Side La, Blackpool, Lancashire, FY4 4AA" lng="-3.030698" lat="53.794399" category="theatre" />
  4. <marker name="Tram Shed Theatre" address="7 Moor Pk Av, Blackpool, Lancashire, FY2 0LT" lng="-3.034974" lat="53.845938" category="theatre" />
  5. <marker name="Thornton Little Theatre" address="Fleetwood Road North, Thornton Cleveleys, FY5 3SZ" lng="-3.010607" lat="53.872058" category="theatre" />
  6. <marker name="Barbara Jackson Arts" address="Rossall La, Fleetwood, Lancashire, FY7 8JP" lng="-3.033960" lat="53.897928" category="theatre" />
  7. <marker name="North Shore Golf Club" address="Devonshire Rd, Blackpool, Lancashire, FY2 0RD" lng="-3.043305" lat="53.839898" category="golf" />
  8. <marker name="St Annes Old Links" address="Highbury Road East, Lytham St. Annes, Lancashire, FY8 2LD" lng="-3.038407" lat="53.762917" category="golf" />
  9. <marker name="Fairhaven Golf Club" address="Oakwood Av, Lytham St. Annes, Lancashire, FY8 4JU" lng="-2.983218" lat="53.742781" category="golf" />
  10. <marker name="Green Drive Golf Club" address="Ballam Rd, Lytham St. Annes, Lancashire, FY8 4LE" lng="-2.959530" lat="53.745971" category="golf" />
  11. <marker name="Fleetwood Golf Club" address="Princes Wy, Fleetwood, Lancashire, FY7 8AF" lng="-3.042973" lat="53.917606" category="golf" />
  12. <marker name="Knott End Golf Club" address="Wyre Side, Knott End-on-Sea, Poulton-le-Fylde, Lancashire, FY6 0AA" lng="-2.997062" lat="53.923200" category="golf" />
  13. <marker name="Tourist Information 1" address="1 Clifton St, Blackpool, Lancashire, FY1 1LY" lng="-3.054529" lat="53.818775" category="info" />
  14. <marker name="Tourist Information 2" address="Thornton-Cleveleys, Lancashire, FY5 1WA" lng="-3.042989" lat="53.876079" category="info" />
  15. <marker name="Tourist Information 3" address="Victoria Rd West, Thornton-Cleveleys, Lancashire, FY5 1AJ" lng="-3.041668" lat="53.877403" category="info" />
  16. <marker name="Tourist Information 4" address="St. Annes Rd West, Lytham St. Annes, Lancashire, FY8 1SA" lng="-3.031074" lat="53.752122" category="info" />
  17. <marker name="Tourist Information 5" address="The Esplanade, Fleetwood, Lancashire, FY7 6DL" lng="-3.006366" lat="53.926970" category="info" />
  18. <marker name="Tourist Information 6" address="10-12 York St, Blackpool, Lancashire, FY1 5AQ" lng="-3.052919" lat="53.810556" category="info" />
  19. </markers>

Mam problem z kodowaniem. Co w takim razie mogę zrobić? Dodawałem:
  1. <?xml version="1.0" encoding="iso-8859-2"?>
, ale nic nie pomogło.

Tu zamieszczam kod html/js - może w nim tkwi problem:
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <head>
  3. <meta http-equiv="content-type" content="text/html; charset=iso-8859-2" />
  4. <meta http-equiv="content-language" content="pl" />
  5. <title>Google Maps</title>
  6. <script src="klucz api" type="text/javascript"></script> </head>
  7. <body onunload="GUnload()">
  8.  
  9.  
  10. <!-- you can use tables or divs for the overall layout -->
  11. <table border=1>
  12. <tr>
  13. <td>
  14. <div id="map" style="width: 550px; height: 450px"></div>
  15. </td>
  16. <td width = 150 valign="top" style="text-decoration: underline; color: #4444ff;">
  17. <div id="side_bar"></div>
  18. </td>
  19. </tr>
  20. </table>
  21. <form action="#">
  22. Urzędy: <input type="checkbox" id="theatrebox" onclick="boxclick(this,'urzedy')" /> &nbsp;&nbsp;
  23. Kultura: <input type="checkbox" id="golfbox" onclick="boxclick(this,'kultura')" /> &nbsp;&nbsp;
  24. Sport: <input type="checkbox" id="golfbox" onclick="boxclick(this,'sport')" /> &nbsp;&nbsp;
  25. Apteki: <input type="checkbox" id="golfbox" onclick="boxclick(this,'apteki')" /> &nbsp;&nbsp;
  26. Bankomaty: <input type="checkbox" id="infobox" onclick="boxclick(this,'bankomaty')" /><br />
  27. </form>
  28.  
  29.  
  30. <a href="categories.htm">Back to the tutorial page</a>
  31.  
  32.  
  33. <noscript><b>JavaScript must be enabled in order for you to use Google Maps.</b>
  34. However, it seems JavaScript is either disabled or not supported by your browser.
  35. To view Google Maps, enable JavaScript by changing your browser options, and then
  36. try again.
  37.  
  38.  
  39. <script type="text/javascript">
  40. //<![CDATA[
  41.  
  42. if (GBrowserIsCompatible()) {
  43. var gmarkers = [];
  44. var gicons = [];
  45.  
  46. var baseIcon = new GIcon(G_DEFAULT_ICON);
  47. baseIcon.iconAnchor = new GPoint(9,34);
  48. baseIcon.iconSize = new GSize(20,34);
  49. baseIcon.infoWindowAnchor = new GPoint(9,2);
  50.  
  51.  
  52. gicons["urzedy"] = new GIcon(baseIcon,"/images/logo.png");
  53. gicons["kultura"] = new GIcon(baseIcon,"colour108.png");
  54. gicons["sport"] = new GIcon(baseIcon,"colour125.png");
  55. gicons["apteki"] = new GIcon(baseIcon,"colour125.png");
  56. gicons["bankomaty"] = new GIcon(baseIcon,"colour125.png");
  57.  
  58. // A function to create the marker and set up the event window
  59. function createMarker(point,name,html,category) {
  60. var marker = new GMarker(point,gicons[category]);
  61. // === Store the category and name info as a marker properties ===
  62. marker.mycategory = category;
  63. marker.myname = name;
  64. GEvent.addListener(marker, "click", function() {
  65. marker.openInfoWindowHtml(html);
  66. });
  67. gmarkers.push(marker);
  68. return marker;
  69. }
  70.  
  71. // == shows all markers of a particular category, and ensures the checkbox is checked ==
  72. function show(category) {
  73. for (var i=0; i<gmarkers.length; i++) {
  74. if (gmarkers[i].mycategory == category) {
  75. gmarkers[i].show();
  76. }
  77. }
  78. // == check the checkbox ==
  79. document.getElementById(category+"box").checked = true;
  80. }
  81.  
  82. // == hides all markers of a particular category, and ensures the checkbox is cleared ==
  83. function hide(category) {
  84. for (var i=0; i<gmarkers.length; i++) {
  85. if (gmarkers[i].mycategory == category) {
  86. gmarkers[i].hide();
  87. }
  88. }
  89. // == clear the checkbox ==
  90. document.getElementById(category+"box").checked = false;
  91. // == close the info window, in case its open on a marker that we just hid
  92. map.closeInfoWindow();
  93. }
  94.  
  95. // == a checkbox has been clicked ==
  96. function boxclick(box,category) {
  97. if (box.checked) {
  98. show(category);
  99. } else {
  100. hide(category);
  101. }
  102. // == rebuild the side bar
  103. makeSidebar();
  104. }
  105.  
  106. function myclick(i) {
  107. GEvent.trigger(gmarkers[i],"click");
  108. }
  109.  
  110.  
  111. // == rebuilds the sidebar to match the markers currently displayed ==
  112. function makeSidebar() {
  113. var html = "";
  114. for (var i=0; i<gmarkers.length; i++) {
  115. if (!gmarkers[i].isHidden()) {
  116. html += '<a href="java script:myclick(' + i + ')">' + gmarkers[i].myname + '<\/a><br>';
  117. }
  118. }
  119. document.getElementById("side_bar").innerHTML = html;
  120. }
  121.  
  122.  
  123. // create the map
  124. var map = new GMap2(document.getElementById("map"));
  125. map.addControl(new GLargeMapControl());
  126. map.addControl(new GMapTypeControl());
  127. map.setCenter(new GLatLng(52.078873,21.023884), 14);
  128.  
  129.  
  130. // Read the data
  131. GDownloadUrl("categories.xml", function(doc) {
  132. var xmlDoc = GXml.parse(doc);
  133. var markers = xmlDoc.documentElement.getElementsByTagName("marker");
  134.  
  135. for (var i = 0; i < markers.length; i++) {
  136. // obtain the attribues of each marker
  137. var lat = parseFloat(markers[i].getAttribute("lat"));
  138. var lng = parseFloat(markers[i].getAttribute("lng"));
  139. var point = new GLatLng(lat,lng);
  140. var address = markers[i].getAttribute("address");
  141. var name = markers[i].getAttribute("name");
  142. var html = "<b>"+name+"<\/b><p>"+address;
  143. var category = markers[i].getAttribute("category");
  144. // create the marker
  145. var marker = createMarker(point,name,html,category);
  146. map.addOverlay(marker);
  147. }
  148.  
  149. // == show or hide the categories initially ==
  150. hide("urzedy");
  151. hide("kultura");
  152. hide("sport");
  153. hide("apteki");
  154. hide("bankomaty");
  155. // == create the initial sidebar ==
  156. makeSidebar();
  157. });
  158. }
  159.  
  160. else {
  161. alert("Sorry, the Google Maps API is not compatible with this browser");
  162. }
  163. // This Javascript is based on code provided by the
  164. // Community Church Javascript Team
  165.  
  166. //]]>
  167. </script>
  168. </body>
  169.  
  170. </html>