0

To cut a long story short i'm attempting to modify this example from Google: http://storelocator.googlecode.com/git/examples/custom.html to come from some XML instead.

The store locator API is here: http://storelocator.googlecode.com/git/index.html

As far as I can tell the code i've got is working ok, but for some reason I get a

TypeError: this.b is undefined

in firebug and no markers show. I revert it back to the CSV and it works, so I can only assume i'm not passing something.

For some reason I can't get the jsfiddle to even show the map: http://jsfiddle.net/tmtJz/4/ So i've upload the files here: http://www.speedyshare.com/CSm8j/storelocator.zip (click on the link at the top to download)

The main bit i've changed is:

    /**
 * @private
 * @param {string} csv
 * @return {!Array.<!storeLocator.Store>}
 */
tcmapData.prototype.parse_ = function() {
  var stores = [];

var xml='<markers><marker><name>1</name> <lat>53.043041229248</lat> <lng>-2.9924941062927</lng> </marker><marker><name>2</name> <lat>53.544544219971</lat> <lng>-2.1187319755554</lng> </marker></markers>';

     $(xml).find("marker").each(function() {
  var marker = $(this);
  //alert(marker.find('lat').text());


                var features = new storeLocator.FeatureSet;
              features.add(tcmapData.prototype.FEATURES_.getById('ServiceDepot-YES'));

              var position = new google.maps.LatLng(marker.find('lng').text(), marker.find('lat').text());

              var store = new storeLocator.Store(marker.find('name').text(), position, features, {
                title: marker.find('name').text(),
                address: 'Test Address',
                  hours: '9-5',
                  servicedepot: "YES"
               // servicedepot: row.Service_Depot
              });

                            stores.push(store);


});

};

If someone could help I would be internally grateful as I'm loosing the will the live trying to figure it out, but I think i'm close!

Thank You.

4

1 回答 1

2

总是简单的东西。

只是忘记在最后一行之前返回商店......

  return stores;

:( 花费数小时试图弄清楚!

如果其他人收到此错误,请务必检查以上内容!

于 2013-04-16T09:48:57.730 回答