简体   繁体   English

jQuery商店定位器标记

[英]jQuery store locator markers

I'm new to jQuery and have been playing with the jQuery store locator plugin. 我是jQuery新手,一直在使用jQuery商店定位器插件。

What I'm wanting to do is, change the markers from the letter markers to the normal markers with the black dot. 我要做的是,将带有黑点的标记从字母标记更改为普通标记。 I have tried doing this but keep getting syntax errors or nothing comes up at all. 我曾尝试这样做,但一直收到语法错误,否则什么都不会发生。

Another thing I have being trying to do is have more than one store locator on screen or show multiple XML files. 我正在尝试做的另一件事是在屏幕上有多个商店定位器或显示多个XML文件。 Is this possible? 这可能吗? I have tried but not got anywhere with it. 我已经尝试过了,但是却一无所获。

Lastly, I was wondering if I could get multiple XML files working? 最后,我想知道是否可以使多个XML文件正常工作? Is it possible to have say 4 main markers, then when a user presses a red mark say for hardware stores, the map will just show all hardware stores, or he/she presses say a blue marker he/she gets just grocery stores? 是否可以说4个主要标记,然后当用户按红色标记对硬件商店说时,地图将仅显示所有硬件商店,或者他/她按说蓝色标记以使他/她得到杂货店?

I hope this makes sense, and I'm very sorry if this question as been asked before. 我希望这是有道理的,如果对此问题像以前那样提出,我感到非常抱歉。 I couldn't find anything about it. 我什么都找不到。

sorry for the delay in replying 很抱歉延迟回复

jquery.storelocator.js jquery.storelocator.js

this is the bit of code I am having trouble editing. 这是我在编辑时遇到的麻烦的代码。 Every time I try to change the var pinImage line i get a syntax error 每次尝试更改var pinImage行时,我都会收到语法错误

//Custom marker function - aplhabetical
  function createMarker(point, letter, pinColor) {
//Set up pin icon with the Google Charts API for all of our markers

  var pinImage = new google.maps.MarkerImage("http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=" + letter + "|" + pinColor + "|" + settings.pinTextColor,

  new google.maps.Size(21, 34),
  new google.maps.Point(0, 0),
  new google.maps.Point(10, 34));
  var pinShadow = new google.maps.MarkerImage("http://chart.apis.google.com/chart?chst=d_map_pin_shadow",
  new google.maps.Size(40, 37),
  new google.maps.Point(0, 0),
  new google.maps.Point(12, 35));

 //Create the markers
   return new google.maps.Marker({
   position: point,
   map: map,
   icon: pinImage,
   shadow: pinShadow,
   draggable: false

Edited version of the above code 上面代码的编辑版本

//Custom marker function - aplhabetical
  function createMarker(point, letter, pinColor) {
//Set up pin icon with the Google Charts API for all of our markers

  var pinImage = new google.maps.MarkerImage("http://chart.apis.google.com/chart?chst=d_map_pin_icon&chld=" + location + "|" + pinColor + "|" + settings.pinTextColor,

  new google.maps.Size(21, 34),
  new google.maps.Point(0, 0),
  new google.maps.Point(10, 34));
  var pinShadow = new google.maps.MarkerImage("http://chart.apis.google.com/chart?chst=d_map_pin_shadow",
  new google.maps.Size(40, 37),
  new google.maps.Point(0, 0),
  new google.maps.Point(12, 35));

 //Create the markers
   return new google.maps.Marker({
   position: point,
   map: map,
   icon: pinImage,
   shadow: pinShadow,
   draggable: false

thank you for your help on the marker bit. 感谢您对标记位的帮助。

Yes I am using single xmls for each store, and this is the code I am using for each xml 是的,我为每个商店使用单个xml,这是我为每个xml使用的代码

trout.xml trout.xml

<?xml version="1.0" encoding="UTF-8"?>
  <kml xmlns="http://earth.google.com/kml/2.2">
<Document>
  <name>trout</name>
<description><![CDATA[Trout fishing (plain text version)]]></description>
<Placemark>
<name>some trout place - burnley</name>
<Snippet>some trout place in burnley </Snippet>
<description><![CDATA[<div dir="ltr">trout place 1 - burnley<br>some street<br>bb12 3ab<br>01234 567890</div>]]></description>
<Point>
  <coordinates>-2.104521,57.145737,0.000000</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Nelson</name>
<Snippet>Some trout place nelson</Snippet>
<description><![CDATA[<div dir="ltr">Some trout place nelson1 <br>some street<br>Nelson<br>Bb12 3ac<br>01234 567890</div>]]></description>
<Point>
  <coordinates>-5.962432,54.570358,0.000000</coordinates>
</Point>

salmon.xml salmon.xml

<?xml version="1.0" encoding="UTF-8"?>
 <kml xmlns="http://earth.google.com/kml/2.2">
<Document>
<name>Salmon</name>
<description><![CDATA[salmon fishing in the uk (plain text version)]]></description>
<Placemark>
<name>Burnley</name>
<Snippet>Salmon fishing place1 goes here</Snippet>
<description><![CDATA[<div dir="ltr">Salmon Fishing Place - Burnley<br>Some Street<br>Burnley<br>bb12 3ab<br>01234 567890</div>]]></description>
<Point>
  <coordinates>-2.2450,53.7877,0.000000</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Nelson</name>
<Snippet>Salmon fishing place2 goes herei</Snippet>
<description><![CDATA[<div dir="ltr">Salmon Fishing place2 - Nelson<br>Some Street<br>Nelson<br>BB12 3ac<br>01234 567890</div>]]></description>
<Point>
  <coordinates>-5.962432,54.570358,0.000000</coordinates>
</Point>
</Placemark>

this is where i am placing the files 这是我放置文件的地方

Jquery.storelocator.js Jquery.storelocator.js

(function ($) {
$.fn.storeLocator = function (options) {

    var settings = $.extend({
        'mapDiv': 'map',
        'listDiv': 'list',
        'formID': 'user-location',
        'pinColor': 'fe7569',
        'startPinColor': '66bd4a',
        'pinTextColor': '000000',
        'storeLimit': 10,
        'distanceAlert': 60,
        'xmlLocation': 'data/trout.xml',
        'xmlLocation': 'data/salmon.xml',
        'addressErrorMsg': 'Please enter valid UK address address or postcode',
        'googleDistanceMatrixDestinationLimit': 25,
        'defaultLat': 52.3038165,
        'defaultLng': -1.081117,
        'defaultLocationName': 'Northampton, United Kingdom'
    }, options);

    return this.each(function () {
        var $this = $(this);

        // global array of shop objects
        var _locationset = new Array();
        var geocoder;

You want to ditch the custom letter markers and use the simple "default" markers? 您要放弃自定义字母标记并使用简单的“默认”标记吗? Did I understand it right? 我明白吗? It should be as simple as tossing all the extra options and reducing the function to this: 它应该像扔掉所有其他选项并简化功能一样简单:

//Custom marker function
  function createMarker(point) {

 //Create the markers
   return new google.maps.Marker({
   position: point,
   map: map,
   draggable: false
   });
  }

About the multiple XML files, the closest thing I've tried is placing multiple KmlLayers and it works. 关于多个XML文件,我尝试过的最接近的方法是放置多个KmlLayers,它可以工作。 If you're reading data from several XMLs, I believe building up information should work fine. 如果您要从几种XML读取数据,我相信建立信息应该可以正常工作。 Can you be more specific? 你可以说得更详细点吗? Is a single XML file used for each type of store? 每种商店都使用单个XML文件吗? Show us what you have coded for the multiple XMLs? 告诉我们您为多种XML编码的内容?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM