Opa,
I have two maps on my page, one of them will need to implement Drawing, but, it is not working, to call it I'm using it.
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);
}
});
Normally loads, without drawing, in the documentation I checked the need to insert the code below, for the map to make Drawing options available.
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 in no way did it work, in the console comes the error:
Uncaught SyntaxError: Unexpected identifier
(na linha: var drawingManager = new google.maps.drawing.DrawingManager({)
Can anyone help me?
The code block looks 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 js call is
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=minha-key&libraries=places,drawing"></script>