Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Closed Thread
Google Maps API- help!
Old 10-26-2008, 08:42 PM Google Maps API- help!
Average Talker

Posts: 24
Location: Boston, MA
Trades: 0
Perhaps this would have been better placed in the Javascript, but I felt it'd get a better response here.

I have an XML file with the following values in:

'postcode' (zip code in UK) stored in a db
'username' - username stored in a db

All I'm trying to do is display the contents of the XML file via Google Maps, so that a marker appears on every postcode. I'm getting a weird error that causes the Google Maps marker to appear 5 miles out to sea... Anyone know why this could be? Here is my code.

Code:
    <script type="text/javascript">
    //<![CDATA[

    var iconBlue = new GIcon(); 
    iconBlue.image = 'http://labs.google.com/ridefinder/images/mm_20_blue.png';
    iconBlue.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
    iconBlue.iconSize = new GSize(12, 20);
    iconBlue.shadowSize = new GSize(22, 20);
    iconBlue.iconAnchor = new GPoint(6, 20);
    iconBlue.infoWindowAnchor = new GPoint(5, 1);


    function load() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(50, -0.0), 8);

        GDownloadUrl("genxml.php", function(data) {
          var xml = GXml.parse(data);
          var markers = xml.documentElement.getElementsByTagName("marker");
          for (var i = 0; i < markers.length; i++) {
            var name = markers[i].getAttribute("postcode");
            var marker = createMarker(name);
            map.addOverlay(marker);
          }
        });
      }
    }

    function createMarker(name) {
      var marker = new GMarker;
      var html = "<b>" + name + "</b> <br/>";
      GEvent.addListener(marker, 'click', function() {
        marker.openInfoWindowHtml(html);
      });
      return marker;
    }
    //]]>
  </script>
The XML file is fine, and is called genxml.php above.
__________________

Please login or register to view this content. Registration is FREE

Last edited by spunko2010; 10-26-2008 at 08:51 PM..
spunko2010 is offline
View Public Profile
 
 
Register now for full access!
Old 10-28-2008, 06:33 AM Re: Google Maps API- help!
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
On the strength of information given ....


absolutely no idea.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
View Public Profile Visit chrishirst's homepage!
 
Closed Thread     « Reply to Google Maps API- help!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.09470 seconds with 12 queries