我是jQuery的新手,并且一直在玩jQuery商店定位器插件。
我想要做的是,用黑点将标记从字母标记更改为普通标记。我已经尝试过这样做,但不断出现语法错误或根本没有任何问题。
我要做的另一件事是在屏幕上有多个商店定位器或显示多个XML文件。这可能吗?我已经尝试但没有随处可见。
最后,我想知道我是否可以使用多个XML文件?是否有可能说出4个主要标记,然后当用户按下红色标记表示硬件商店时,地图将只显示所有硬件商店,或者他/她按下说他/她只是杂货店的蓝色标记? / p>
我希望这是有道理的,如果以前曾经问过这个问题,我很抱歉。我找不到任何关于它的信息。
抱歉延迟回复
jquery.storelocator.js
这是我编辑时遇到的一些代码。每次我尝试更改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
上述代码的编辑版
//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
答案 0 :(得分:1)
感谢您对标记位的帮助。
是的我为每个商店使用单个xmls,这是我为每个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
<?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>
这是我放置文件的地方
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;
答案 1 :(得分:0)
你想抛弃自定义字母标记并使用简单的“默认”标记?我明白了吗?它应该像抛弃所有额外的选项并将功能简化为:
//Custom marker function
function createMarker(point) {
//Create the markers
return new google.maps.Marker({
position: point,
map: map,
draggable: false
});
}
关于多个XML文件,我尝试过的最接近的是放置多个KmlLayers并且它可以工作。如果您正在从多个XML中读取数据,我相信构建信息应该可以正常工作。你可以说得更详细点吗?是否为每种类型的商店使用单个XML文件?向我们展示您为多个XML编码的内容?