Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle Maps API not centering the Marker
    primarykey
    data
    text
    <p>I have Google Maps on a website that sets the marker based on an address.</p> <p>Here's an example (click the location tab): <a href="http://www.weddinghouse.com.au/wedding-directory/zoning-in-personal-training/" rel="nofollow noreferrer">http://www.weddinghouse.com.au/wedding-directory/zoning-in-personal-training/</a></p> <p>As you can see there is no marker on the map. But if you scroll upwards the marker is sitting just out of view.</p> <p>Is there something wrong with my code? The weird thing is very few addresses actually show correctly but the majority don't. Is there something wrong with my code or is it Google?</p> <p>Here is my JavaScript Code:</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function(){ load('Zoning In Personal Training', '27 Sitella Drive, berwick, VIC, 3806'); }); &lt;/script&gt; </code></pre> <p>-</p> <pre><code>function load(title, address, type) { if (GBrowserIsCompatible()) { var map; var geocoder; map_id = document.getElementById("map"); map = new GMap2(map_id); map.addControl(new GSmallMapControl()); map.setCenter(new GLatLng(24, 0), 17); map.enableDoubleClickZoom(); if (type == 'sat') { map.setMapType(G_SATELLITE_MAP); map.addControl(new GHierarchicalMapTypeControl()); } else { map.setMapType(G_NORMAL_MAP); } geocoder = new GClientGeocoder(); geocoder.getLocations(address, function (response) { map.clearOverlays(); if (!response || response.Status.code != 200) { //map_id.innerHTML('Could not find address on Google Maps'); } else { place = response.Placemark[0]; point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]); map.setCenter(point, 17); // Create our "tiny" marker icon var icon = new GIcon(); icon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png"; icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png"; icon.iconSize = new GSize(12, 20); icon.shadowSize = new GSize(22, 20); icon.iconAnchor = new GPoint(6, 20); icon.infoWindowAnchor = new GPoint(5, 1); // Creates one of our tiny markers at the given point function createMarker(point, index) { var marker = new GMarker(point, icon); var myMarkerContent = "&lt;div style=\"width:200px; overflow:auto;\"&gt;&lt;strong&gt;" + title + "&lt;/strong&gt;&lt;br /&gt;" + address + "&lt;/div&gt;"; map.addOverlay(marker); marker.openInfoWindowHtml(myMarkerContent); GEvent.addListener(marker,"click",function() { marker.openInfoWindowHtml(myMarkerContent); }); } createMarker(point); } }); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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