Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle Maps Store Locator Click Jumps to Top of Page
    primarykey
    data
    text
    <p>I have a Store Locator and every time I click on an anchor (such as Zoom Here, Directions, or Street View), the hash in the href takes me to the top of the page. How can I prevent this from happening? I tried looking through the Store Locator source, but it's minified and hard to figure out what is what. I also tried adding event delegation to anchors with class "action" but this didn't work either.</p> <p>Main function</p> <pre><code>google.maps.event.addDomListener(window, 'load', function() { var map = new google.maps.Map(document.getElementById('mappanel'), { center: new google.maps.LatLng(56.102683, 10.452576), zoom: 7, mapTypeId: google.maps.MapTypeId.ROADMAP }); var panelDiv = document.getElementById('searchpanel'); var data = new storeSource; var view = new storeLocator.View(map, data, { geolocation: false }); new storeLocator.Panel(panelDiv, { view: view }); }); </code></pre> <p>storeLocator class</p> <pre><code>/** @extends storeLocator.StaticDataFeed */ function storeSource() { jQuery.extend(this, new storeLocator.StaticDataFeed); var that = this; jQuery.get('/components/com_maps/storeSource.csv', function(data) { that.setStores(that.parse_(data)); }); } /** @private */ storeSource.prototype.parse_ = function(csv) { var stores = []; var rows = csv.split('\r'); var headings = this.parseRow_(rows[0]); for (var i = 1, row; row = rows[i]; i++) { row = this.toObject_(headings, this.parseRow_(row)); if(row.adresse.length &gt; 3) { row.lat = row.lat.replace(",", "."); row.lng = row.lng.replace(",", "."); var position = new google.maps.LatLng(row.lat, row.lng); var locality = this.join_([row.postnr, row.by], ', '); var store = new storeLocator.Store(row.uid, position, null, { title: row.navn, address: this.join_([row.adresse, locality, row.land], '&lt;br&gt;'), phone: row.tlfnr }); stores.push(store); } } return stores; }; /** Joins elements of an array that are non-empty and non-null. */ storeSource.prototype.join_ = function(arr, sep) { var parts = []; for (var i = 0, ii = arr.length; i &lt; ii; i++) { arr[i] &amp;&amp; parts.push(arr[i]); } return parts.join(sep); }; /*** CSV parsing */ storeSource.prototype.parseRow_ = function(row) { // Each row in the CSV file only has ; as delimiter row = row.split(';'); return row; }; /** Creates an object mapping headings to row elements. */ storeSource.prototype.toObject_ = function(headings, row) { var result = {}; for (var i = 0, ii = row.length; i &lt; ii; i++) { result[headings[i]] = row[i]; } return result; }; </code></pre> <p>Here's a link to the Store Locator library: <a href="http://storelocator.googlecode.com/git/index.html" rel="nofollow">http://storelocator.googlecode.com/git/index.html</a></p>
    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.
 

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