Google Maps Javascript API: marker.setPosition Issue

It's probably something obvious... but I cannot see it. The following code works as expected for everything except the marker.setPosition action:

<title>Test Simulation</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
  html { height: 100% }
  body { height: 100%; margin: 0; padding: 0 }
  #map_canvas { height: 100% }
<script type="text/javascript"  src="">

<script type="text/javascript">
  var marker = null;
  var myLatlng = null;
  var map = null;
  var image = null;
  var mapOptions = null

  function movemarker()
    xmlhttp=new XMLHttpRequest();"GET","",false);

    var data = xmlhttp.responseText;
    vals = data.split(',');
    latv = parseFloat(vals[0]);
    lonv = parseFloat(vals[1]);
    myLatlng = new google.maps.LatLng(latv,lonv);

    var fld = document.getElementById('before_map');
    fld.innerText = ' ' + 'lat:' + latv + ', lon: ' + lonv + ' ' + myLatlng.toString();
    marker.setPosition = myLatlng;

  function initialize()
    myLatlng = new google.maps.LatLng(44.809122,-36.650391);
    mapOptions = 
      center: myLatlng,
      zoom: 3,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    map = new google.maps.Map(document.getElementById("map_canvas"),

    image = '';
    marker = new google.maps.Marker(
      position: myLatlng,
      map: map,
      icon: image,
      title:"Hello World!"

<body onload="initialize(); ">
<div id="before_map">Test area...</div>
<div id="map_canvas" style="align:right; width:600; height:500"></div>

The "before_map" test area shows the new latitude and longitude values -- which update every 5 seconds.

I've made adjustments based on answers to similar questions but I'm still stuck.


setPosition is a method. You need to modify your code to


Please check whether it works.

marker.setPosition is a function, not a property, I think you want


Need Your Help

Hide element, but show CSS generated content

html css css-selectors

Is there a way of hiding an element's contents, but keep its :before content visible?

Why does casting a NaN to a long yield a valid result?


In the sample code below I am dividing by zero which when I step through it with the debugger the (dividend / divisor) yields an Infinity or NaN (if the divisor is zero). When I cast this result t...