javascript - Object doesn't support property or method 'setMap' -


i designing code jquerymobile, , weird error (that did not before): object doesn't support property or method 'setmap'. result, getcurrentposition not working properly, , can't actual user's position.

this code links:

<link href="omgapp-theme/themes/jquery.mobile.icons.min.css" rel="stylesheet" /> <link href="omgapp-theme/themes/omgapptheme.css" rel="stylesheet" /> <link href="omgapp-theme/themes/omgapptheme.min.css" rel="stylesheet" />   <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile.structure-1.4.5.min.css" /> <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script> <script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>   <!-- menu --> <link rel="stylesheet" href="assets/css/styles.css" /> <link rel="stylesheet" href="assets/font-awesome/css/font-awesome.css" />   <!--autocomplete--> <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"> <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>   <!--**************************************popup info************************************--> <link href="the-modal-master/demo-modals.css" rel="stylesheet" /> <script src="the-modal-master/jquery.the-modal.js"></script> <link href="the-modal-master/the-modal.css" rel="stylesheet" />   <script src="ajaxcall.js"></script>  <style type="text/css">     /*this css code  makes maps work jquerymobile*/      #content {         padding: 0 !important;         position: absolute !important;         top: 40px !important;         right: 0 !important;         bottom: 40px !important;         left: 0 !important;     }      #gpsicon {         height: 2em;     }      html, body, #map-canvas {         height: 450px;         margin: 0px;         padding: 0px;     }      html, body, #map-canvas1 {         height: 450px;         margin: 0px;         padding: 0px;     }      html, body, #map-canvas2 {         height: 450px;         margin: 0px;         padding: 0px;     }      p.marker {         color: black;         direction: rtl;         font-family: arial;     }      [data-role=footer] {         bottom: 0;         position: absolute !important;         top: auto !important;         width: 100%;     } </style> 

and part creates error:

function getcurrentposition_success(position) {

        if (counter > 0)             (var = 0; < markers.length; i++) {                 markers[i].setmap(null);                 markers = [];                 counter = 0;             }          co = position.coords; // set short variable conviniece         var pos = new google.maps.latlng(co.latitude, co.longitude);         var marker1 = {//the radius marker             strokecolor: '#0000ff',             strokeopacity: 0.5,             strokeweight: 2,             fillcolor: '#0000ff',             fillopacity: 0.35,             map: map,             center: pos,             radius: 5,             title: 'you here',         };         circleradius = new google.maps.circle(marker1);         markers.push(marker1);         counter++;         map.setcenter(pos); // center map around position of user          request = {             nodenumber: num,//destnum             posx: co.latitude,             posy: co.longitude         }         getdistance(request, getdistancesuccesscb, getdistanceerrorcb);      } 

you setting marker1 javascript object , not google maps marker object, , doesnt have setmap() method google markers do. set maps marker object need use

var marker1 = new google.maps.marker({ 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -