Reputation: 41
I'm new to jQuery and have been playing with the jQuery store locator plugin.
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. Is this possible? I have tried but not got anywhere with it.
Lastly, I was wondering if I could get multiple XML files working? 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?
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
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
//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
Upvotes: 2
Views: 2296
Reputation: 41
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
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>
this is where i am placing the files
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;
Upvotes: 1
Reputation: 6779
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. If you're reading data from several XMLs, I believe building up information should work fine. Can you be more specific? Is a single XML file used for each type of store? Show us what you have coded for the multiple XMLs?
Upvotes: 0