• I am attempting to draw a circle with a 20km radius around the center point of my map (the location of my business). I’m trying to represent our service area.

    Below is the code I have added, anyone have any idea as to why it’s not working for me?

    <script type="text/javascript">
                var map_<?php echo $map_id; ?>;
                function pw_run_map_<?php echo $map_id; ?>(){
    
                    var location = new google.maps.LatLng("<?php echo $coordinates['lat']; ?>", "<?php echo $coordinates['lng']; ?>");
    
                    var map_options = {
                        zoom: 16,
                        center: location,
                        mapTypeId: google.maps.MapTypeId.ROADMAP
                    }
    
                    map_<?php echo $map_id ; ?> = new google.maps.Map(document.getElementById("<?php echo $map_id ; ?>"), map_options);
    
                    var marker = new google.maps.Marker({
                        position: location,
                        map: map_<?php echo $map_id; ?>
                    });
    
                    var circle = new google.maps.Circle({
                      map: map_<?php echo $map_id; ?>
                      radius: 20000,
                      fillColor: '#AA0000'
                    });
    
                    circle.bindTo('center', marker, 'position');
    
                }
    
                pw_run_map_<?php echo $map_id; ?>();
            </script>

    https://www.ads-software.com/plugins/simple-google-maps-short-code/

  • The topic ‘Drawing a circle on the map’ is closed to new replies.