Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Javascript
function initialize() {
       var mapOptions = {
 

           mapTypeId: google.maps.MapTypeId.ROADMAP
       };
 
       var map = new google.maps.Map(document.getElementById('googleMap'),
   mapOptions);
       // map.getHeading();
       var defaultBounds = new google.maps.LatLngBounds(
     new google.maps.LatLng(-33.8902, 151.1759),
     new google.maps.LatLng(-33.8474, 151.2631));
       map.fitBounds(defaultBounds);
 
       var input = (document.getElementById('target'));
       var searchBox = new google.maps.places.SearchBox(input);
       var markers = [];
 
       google.maps.event.addListener(searchBox, 'places_changed', function () {
           var places = searchBox.getPlaces();
 
           for (var i = 0, marker; marker = markers[i]; i++) {
               marker.setMap(null);
           }
 
           markers = [];
           var bounds = new google.maps.LatLngBounds();
           for (var i = 0, place; place = places[i]; i++) {
               var image = {
                   url: place.icon,
                   size: new google.maps.Size(71, 71),
                   origin: new google.maps.Point(0, 0),
                   anchor: new google.maps.Point(17, 34),
                   scaledSize: new google.maps.Size(25, 25)
               };
 
               var marker = new google.maps.Marker({
                   map: map,
                   icon: image,
                   title: place.name,
                   position: place.geometry.location
               });
 
               markers.push(marker);
 
               bounds.extend(place.geometry.location);
           }
 
           map.fitBounds(bounds);
       });
 
       google.maps.event.addListener(map, 'bounds_changed', function () {
           var bounds = map.getBounds();
           searchBox.setBounds(bounds);
       });
 
       var drawingManager = new google.maps.drawing.DrawingManager({
           drawingMode: google.maps.drawing.OverlayType.MARKER,
           drawingControl: true,
           drawingControlOptions: {
               position: google.maps.ControlPosition.TOP_RIGHT,
               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,
       google.maps.drawing.OverlayType.ERASIER
     ]
           },
 
           circleOptions: {
               fillColor: '#ffff00',
               fillOpacity: 1,
               strokeWeight: 5,
               clickable: false,
               editable: true,
               zIndex: 1
           }
       });
       drawingManager.setMap(map);
   }
google.maps.event.addDomListener(window, 'load', initialize);
In above code only search box is coming but not tool box ,please give tell me any solution.
Posted 28-Apr-13 22:04pm
sagmali308
Edited 28-Apr-13 23:15pm
(no name)114.4K
v3
Comments
Tadit Dash at 29-Apr-13 5:41am
   
If you are using the FireBug in Firefox, then just go to Console Panel in FireBug and check for any errors.
You will find all the mark-up and javaScript errors here. Please review and correct them, if you have any.
 
You can also put debugger in code or in FireBug Script window and see the execution line by line.
ryanb31 at 29-Apr-13 8:17am
   
Step through the code and tell us where it is going wrong.
sagmali at 29-Apr-13 9:46am
   
drawingManager.setMap(map)
this line is not executing

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 341
1 Marcin Kozub 225
2 Sergey Alexandrovich Kryukov 220
3 Praneet Nadkar 197
4 Shweta N Mishra 161
0 OriginalGriff 8,149
1 Sergey Alexandrovich Kryukov 7,287
2 DamithSL 5,614
3 Manas Bhardwaj 4,986
4 Maciej Los 4,910


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 29 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100