Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to draw a circle and search within the circle on a Google Maps API?
    primarykey
    data
    text
    <p>On my web page I have already a Google Maps API with a search bar (see code below) and at first the user pinpoints an address. Then the User is be able to search businesses around this point with a search bar. Before search is complete I'd like to draw a circle around this address for instance with a distance of 15 km. The search should show only results within this circle. It would be nice if you also could move the circle... How can I do this with Google Maps? </p> <pre><code>&lt;script type="text/javascript"&gt; var map = null; var geocoder = null; function initialize() { /* Initialize the Google Maps */ if (GBrowserIsCompatible()) { map = new GMap2(document.getElementById("map")); map.setCenter(new GLatLng(50.786916, 6.101360), 16); var customUI = map.getDefaultUI(); customUI.controls.scalecontrol = false; map.setUI(customUI); var options = { onSearchCompleteCallback:function(searcher){ var resultcontent = ''; if (searcher.results &amp;&amp; searcher.results.length &gt; 0) { $("#ResultGrid").clearGridData(true); for (var i = 0; i &lt; searcher.results.length; i++) { var result = searcher.results[i]; // Split address-lines to get Zipcode TempString = result.addressLines[1]; var ZipCode = TempString.split(/\b[^0-9]/); // construct the data array var InputData = {Firma:result.titleNoFormatting, Adresse:result.addressLines[0], Postleitzahl:ZipCode[0], Ort:result.city, Telefonnummer:result.phoneNumbers[0].number}; // Apply data to grid jQuery("#ResultGrid").addRowData(i, InputData); $("#Result").show("slow"); } } else { $("#Dialog").html("&lt;p&gt;&lt;span class=\"ui-icon ui-icon-info\" style=\"float:left; margin:0 7px 20px 0;\"&gt;&lt;/span&gt;Kein Suchergebnis!&lt;/p&gt;"); $("#Dialog").dialog("option", "title", "Hinweis:"); $("#Dialog").dialog("open"); $("#Dialog").html("Keine Ergebnisse gefunden!"); $("#Dialog").dialog("option", "title", "Hinweis:"); $("#Dialog").dialog("open"); } } }; localSearch = new google.maps.LocalSearch(options); map.addControl(localSearch); map.removeControl(GScaleControl); geocoder = new GClientGeocoder(); $("#map").hide("fast"); $("#Result").hide("fast"); } } function showAddress(address, CompleteAdd) { if (geocoder) { geocoder.getLatLng( address, function(point) { if (!point) { $("#Dialog").html("&lt;p&gt;&lt;span class=\"ui-icon ui-icon-info\" style=\"float:left; margin:0 7px 20px 0;\"&gt;&lt;/span&gt;"+address+" nicht gefunden&lt;/p&gt;"); $("#Dialog").dialog("option", "title", "Hinweis:"); $("#Dialog").dialog("open"); } else { map.setCenter(point, 16); var marker = new GMarker(point); map.addOverlay(marker); marker.openInfoWindowHtml(CompleteAdd); } } ); } $("#map").show("fast"); } &lt;/script&gt; </code></pre> <p></p> <pre><code>&lt;body onload="initialize()" onunload="GUnload()"&gt; &lt;div class="main" align="center"&gt; &lt;div id="Dialog"&gt; &lt;p&gt;&lt;span class="ui-icon ui-icon-info" style="float:left; "&gt;&lt;/span&gt;Dialog text&lt;/p&gt; &lt;/div&gt; &lt;br/&gt; &lt;div id="map" style="width: 850px; height:450px; padding:10px; font-size: medium; color:#853805; background-color:#FFE8CF;"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/body&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload