karthika pommudu

karthika pommudu

  • NA
  • 321
  • 32k

Uncaught TypeError: map.drawCircle is not a function

Mar 19 2019 6:05 AM
Here, the error will shows in this line 'circle = map.drawCircle({ ......
 
Eror:Uncaught TypeError: map.drawCircle is not a function,
 
How do I get past the solution for this?help me to solve this
  1. <script type="text/javascript">  
  2. var poi_coordinates = [[32.27, 77.19],[32.25, 77.22] , [32.23, 77.21], [32.24, 77.17],[26.61,77.19]]  
  3. var lattitude = 32.25; //28.6339;  
  4. var longitude = 77.19; //77.2200;  
  5. //creating map  
  6. var latlng = new google.maps.LatLng(21.16536,72.79387);  
  7. var myOptions = {  
  8. zoom: 5,  
  9. center: latlng,  
  10. mapTypeId: google.maps.MapTypeId.ROADMAP  
  11. };  
  12. map = new google.maps.Map(document.getElementById('map'), myOptions);  
  13. //creating geofence  
  14. circle = map.drawCircle({  
  15. lat: lattitude,  
  16. lng: longitude,  
  17. strokeColor: '#fff',  
  18. strokeOpacity: 1,  
  19. strokeWeight: 3,  
  20. fillColor: 'rgba(75,255,0,0.2)',  
  21. fillOpacity: 0.4,  
  22. radius: 4000,  
  23. editable: true,  
  24. });  
  25. //Plotting Main Coordinates  
  26. map.addMarker({  
  27. lat: lattitude,  
  28. lng: longitude,  
  29. draggable: true,  
  30. fences: [circle],  
  31. outside: function (marker, fence) {  
  32. alert('This marker has been moved outside of its fence');  
  33. }  
  34. });  
  35. //Plotting extra coordinates  
  36. for (var a = 0; a < poi_coordinates.length; a++) {  
  37. if (map.checkGeofence(poi_coordinates[a][0], poi_coordinates[a][1], circle)) {  
  38. //Code work properly as it should if I add this alert line  
  39. //alert(map.checkGeofence(poi_coordinates[a][0], poi_coordinates[a][1], circle))  
  40. map.addMarker({  
  41. lat: poi_coordinates[a][0],  
  42. lng: poi_coordinates[a][1],  
  43. draggable: true,  
  44. fences: [circle],  
  45. outside: function (marker, fence) {  
  46. alert('This marker has been moved outside of its fence');  
  47. }  
  48. });  
  49. }  
  50. else {  
  51. alert(poi_coordinates[a][0] + "," + poi_coordinates[a][1] + ' is out of the 4 Km fence')  
  52. }  
  53. }  
  54. </script>  

Answers (1)