1
Opa,
I have two maps on my page, in one of them will be necessary to implement Drawing, but, it is not working, to call it I am using.
if ($("#geocomplete_rota").length) {
$("#geocomplete_rota").geocomplete({
map: "#submit-map-rota",
details: "form ",
location: new google.maps.LatLng(40.6700, -73.9400),
mapOptions: {
zoom: 14,
scrollwheel: true,
mapTypeId: "roadmap",
disableDefaultUI: false,
mapTypeControl: true,
mapTypeControlOptions: {
position: google.maps.ControlPosition.LEFT_TOP
},
zoomControl: true,
zoomControlOptions: {
position: google.maps.ControlPosition.RIGHT_TOP
},
scaleControl: true,
streetViewControl: true,
streetViewControlOptions: {
position: google.maps.ControlPosition.RIGHT_TOP
},
styles: mapStyle
},
markerOptions: {
draggable: true,
icon: 'images/pin-empty.png'
}
});
$("#geocomplete_rota").bind("geocode:dragged", function(event, latLng) {
$("input[name=lat_rota]").val(latLng.lat());
$("input[name=lng_rota]").val(latLng.lng());
});
}
//redraw map
$("a[href='#tab-map']").click(function() {
if (estateMap) {
setTimeout(function() {
google.maps.event.trigger(estateMap, 'resize');
}, 500);
}
});
$("a[href='#tab-street-view']").click(function() {
if (panorama) {
setTimeout(function() {
panorama.setVisible(true);
}, 500);
}
});
Loads normally, without Drawing, on documentation I checked the need of inserting the code below, for the map to make available the options of Drawing.
var drawingManager = new google.maps.drawing.DrawingManager({
drawingMode: google.maps.drawing.OverlayType.MARKER,
drawingControl: true,
drawingControlOptions: {
position: google.maps.ControlPosition.TOP_CENTER,
drawingModes: [
google.maps.drawing.OverlayType.MARKER,
google.maps.drawing.OverlayType.CIRCLE,
google.maps.drawing.OverlayType.POLYGON,
google.maps.drawing.OverlayType.POLYLINE,
google.maps.drawing.OverlayType.RECTANGLE
]
},
circleOptions: {
fillColor: '#ffff00',
fillOpacity: 1,
strokeWeight: 5,
clickable: false,
editable: true,
zIndex: 1
}
drawingManager.setMap(map),
But, no way I could put to work, on the console I get the error:
Uncaught SyntaxError: Unexpected identifier
(na linha: var drawingManager = new google.maps.drawing.DrawingManager({)
Someone can help me?
The code pad is like this:
if ($("#geocomplete_fixo").length) {
$("#geocomplete_fixo").geocomplete({
map: "#submit-property-map-fixo",
details: "form ",
location: new google.maps.LatLng(40.6700, -73.9400),
mapOptions: {
zoom: 14,
scrollwheel: true,
mapTypeId: "roadmap",
disableDefaultUI: false,
mapTypeControl: true,
mapTypeControlOptions: {
position: google.maps.ControlPosition.LEFT_TOP
},
zoomControl: true,
zoomControlOptions: {
position: google.maps.ControlPosition.RIGHT_TOP
},
scaleControl: true,
streetViewControl: true,
streetViewControlOptions: {
position: google.maps.ControlPosition.RIGHT_TOP
},
styles: mapStyle
},
markerOptions: {
draggable: true,
icon: 'images/pin-empty.png'
},
var drawingManager = new google.maps.drawing.DrawingManager({
drawingMode: google.maps.drawing.OverlayType.MARKER,
drawingControl: true,
drawingControlOptions: {
position: google.maps.ControlPosition.TOP_CENTER,
drawingModes: [
google.maps.drawing.OverlayType.MARKER,
google.maps.drawing.OverlayType.CIRCLE,
google.maps.drawing.OverlayType.POLYGON,
google.maps.drawing.OverlayType.POLYLINE,
google.maps.drawing.OverlayType.RECTANGLE
]
},
circleOptions: {
fillColor: '#ffff00',
fillOpacity: 1,
strokeWeight: 5,
clickable: false,
editable: true,
zIndex: 1
}
drawingManager.setMap(map)
})
});
$("#geocomplete_fixo").bind("geocode:dragged", function(event, latLng) {
$("input[name=lat_fixo]").val(latLng.lat());
$("input[name=lng_fixo]").val(latLng.lng());
});
}
//redraw map
$("a[href='#tab-map']").click(function() {
if (estateMap) {
setTimeout(function() {
google.maps.event.trigger(estateMap, 'resize');
}, 500);
}
});
$("a[href='#tab-street-view']").click(function() {
if (panorama) {
setTimeout(function() {
panorama.setVisible(true);
}, 500);
}
});
The call of js is
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=minha-key&libraries=places,drawing"></script>
Sorry for the answer, distract me, should be a comment
– Marcelo Bonus
google.maps.drawing.DrawingManager({...}); Faltou fechar seu código... drawing com:
);` He doesn’t seem to be complete... I believe it’s a syntax error.– Ivan Ferrer
I checked the code, in fact it was missing close, but, the error still occurs
– sNniffer