Buying Easy $10 for Javascript expert - GoogleMaps problem

Discussion in 'Programming' started by salazie, Apr 1, 2012.

  1. #1
    Hi all, I'll send $10 by PayPal to the first person who can tell me why the following script isn't moving the marker in the browser along the GPX route when I click on the 'Move' link (you'll need to create a GPX file, store it on your web server and update the relevant section of code to refer to the file) - I'll need a fix to the code below and funds will be sent as soon as I have an explanation AND I've tested it on my local dev server. Easiest $10 for a jscript programmer! Please note I'll be out for the next couple of hours but payment will go to the first poster of the solution to this thread (unless I work it out first in which case I'll update thr thread accordingly), thanks!

    <html>
    <head>
    <title>Untitled Page</title>
    <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=__APIKEY__&sensor=false"></script>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
    <script type="text/javascript">
    var map;
    var marker;
    var points = [];
    function initialize() {
    var myOptions = {
    zoom: 8,
    mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById('map_canvas'),
    myOptions);
    $.ajax({
    type: "GET",
    url: "ABC.gpx",
    dataType: "xml",
    success: function(xml) {
    var bounds = new google.maps.LatLngBounds ();
    $(xml).find("rtept").each(function() {
    var lat = $(this).attr("lat");
    var lon = $(this).attr("lon");
    var p = new google.maps.LatLng(lat, lon);
    points.push(p);
    bounds.extend(p);
    });

    var poly = new google.maps.Polyline({
    // use your own style here
    path: points,
    strokeColor: "#FF00AA",
    strokeOpacity: .7,
    strokeWeight: 4
    });

    poly.setMap(map);

    // fit bounds to track
    map.fitBounds(bounds);

    // add a marker
    marker = new google.maps.Marker({
    position: points[0],
    map: map,
    title:"Hello World!",
    clickable: true,
    draggable: true
    });

    }
    });
    }

    google.maps.event.addDomListener(window, 'load', initialize);

    function movemarker() {
    for(var i=0, len=points.length; i < len; i++){
    var p = new google.maps.LatLng(points.Ta, points.Ua);
    marker.setPosition(p);
    wait(10);
    p=null;
    }
    }
    function wait(msecs)
    {
    var start = new Date().getTime();
    var cur = start
    while(cur - start < msecs)
    {
    cur = new Date().getTime();
    }
    }
    </script>
    <style type="text/css">
    #map_canvas {
    margin: 0;
    padding: 0;
    width:500px;height:500px;
    }
    </style>
    </head>
    <body>
    <div id="map_canvas"></div>
    <a href="#" onclick="movemarker();">Move</a>

    </body>
    </html>
     
    salazie, Apr 1, 2012 IP
  2. salazie

    salazie Well-Known Member

    Messages:
    102
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #2
    Hi all, contest cancelled due to lack of response.
     
    salazie, Apr 2, 2012 IP