google maps api 3 - Weird shape drawing position -
i using drawing manager, , if map place in top/left position of screen works perfectly, when map in other position, drawing manager draws line has weird behaviour, "next position point" not centered mouse pointer is.
see picture:
var lat = 40.4167754; var lng = -3.7037901; var mapoptions, map, maker, drawingmanager; function initialize() { mapoptions = { center: { lat: lat, lng: lng }, zoom: 13 }; map = new google.maps.map(document.getelementbyid('map-canvas'), mapoptions); maker = new google.maps.marker({ position: { lat: lat, lng: lng }, map: map }); drawingmanager = new google.maps.drawing.drawingmanager({ drawingmode: google.maps.drawing.overlaytype.polyline, drawingcontrol: true, drawingcontroloptions: { position: google.maps.controlposition.top_center, drawingmodes: [ google.maps.drawing.overlaytype.circle, google.maps.drawing.overlaytype.polyline ] }, circleoptions: { fillcolor: '#ffff00', fillopacity: 1, strokeweight: 5, clickable: false, editable: true, zindex: 1 } }); drawingmanager.setmap(map); } function loadscript() { var script = document.createelement('script'); script.type = 'text/javascript'; script.src = 'https://maps.googleapis.com/maps/api/js?v=3.exp' + '&libraries=geometry,visualization,drawing&signed_in=true&callback=initialize&key=xxx'; document.body.appendchild(script); } $(document).ready(function(){ loadscript(); });
the problem due js version. version 3 works perfectly, not 3.exp
script.src = 'https://maps.googleapis.com/maps/api/js?v=3' + '&libraries=geometry,visualization,drawing&signed_in=true&callback=initialize&key=xxx';
Comments
Post a Comment