5
votes
Accepted
How to programmatically set a Smart Map address field in plugin
I figured it out, didn't realise all I had to do was pass array like so:
$entry->getContent()->address = array('lat' => $lat, 'lng' => $lng, 'street1' => $street1, 'zip' => $...
5
votes
Smart Map cluster marker
Yes, it's definitely possible to cluster your markers with Smart Map.
In fact, anything that you can do with the Google Maps API can also be done with Smart Map:
Manipulating the map in JavaScript
I'...
5
votes
Accepted
Modify ElementCriteria and use it for paginate
You can only modify a craft.entries criteria model with a field (→ Add custom element criteria attribute without a field type?). So what you have to do is to create a new custom field type with your ...
5
votes
How do you auto zoom/center Smart Map with multiple markers?
So for starters, let's clear something up for anyone visiting this thread:
We're talking about JavaScript... specifically, how to manipulate a map that has already been generated. The official ...
5
votes
Filter locations by country in Smart Map
What I've done to do something very similar is to add a template variable to my BusinessLogic plugin, that takes the ElementCriteriaModel, prepared with all other parameters e.g. section, limit and ...
4
votes
Accepted
How do you set a different icon per entry in SmartMap?
That's a tricky one... Natively, all of the options are applied to all markers equally. But you can do a little workaround using something like this pseudo-code:
{% set markerIconJs %}
// On ...
4
votes
Accepted
Smart Map - Sorting for closest location in PHP
You're very close!
$criteria = craft()->elements->getCriteria(ElementType::Entry);
$criteria->myFieldHandle = array(
'target' => 90210,
'range' => 100
);
$criteria->order = '...
4
votes
Accepted
How do I filter by multiple Smart Map addresses?
You would need to setup two criteria models, one for each Smart Map field, and query for the element IDs. Merge these IDs and have a 3rd criteria model where you pass in the IDs to the id parameter.
...
4
votes
Accepted
Adding markers to map from field in entries within section
Author of Smart Map here...
It sounds like your locations are in a section (a Structure is a type of section). The first line of your solution is exactly what you'd need to get the locations value.
{...
4
votes
Accepted
How do I talk to Smart Map in JavaScript?
I'd recommend loading your JS file after the smartmap.js file has been loaded. The smartMap JS object needs to exist before your code gets run.
Try loading your JS using the includeJsFile tag... I ...
4
votes
Accepted
Filter locations by country in Smart Map
At the moment, there's no in-plugin way to handle this. However, you can probably do it out-of-plugin, once you've retrieved a larger set of results.
So first, you'd get the largest possible results ...
4
votes
Accepted
Setting the position of a Smart Map marker on the front end
Turns out my code was pretty much working but there was another issue in there that was stopping the map marker updating. I've since resolved it.
The original form is huge so here's a cut down snippet ...
4
votes
Accepted
How do I differentiate between entries after merging an array?
Not sure if I totally got it but you can check the class of an object via
{% if element is instance of ('craft\\elements\\Entry') %}
or via switch statement
{% switch className(element) %}
{% ...
3
votes
Accepted
Smart Map - Setting single map with multiple pins
According to the docs, locations has to be an array of elements or an ElementCriteriaModel
if you want to display multiple markers.
{% set mapEntries = craft.entries.section('markets') %}
{{ craft....
3
votes
Smart Map plugin - Get visitor's lat/lng
Smart Map can indeed do this! It's currently an undocumented feature, because I wasn't sure if/how it was going to evolve over time. However, that feature has changed very little over the past two ...
3
votes
Nearest entry using related entry Smart Map field
Being that the smartMapField attribute belongs to entries in the Property section, and not the entries in the Unit section, your current element criteria is a bit off (it basically assumes that the ...
3
votes
Smart Map - pass options into markers individually
OK So without being too verbose about this, here is how I managed to attach information to each marker.
It is important to remember that each marker has an ID which corresponds to the entry / user ...
3
votes
Accepted
Getting unique values from Smart Map addresses
You'd actually need to retrieve all of the entries to count them in this way. Once you've got the complete collection, it would simply be a matter of looping through them and adding everything up.
1. ...
3
votes
How can I change the size of an individual pin?
Looks like there are a couple of notable errors in your JS:
You have a semi-colon at the end of your icon line. That should be a comma.
On the scaledSize line, you have the colon inside the quote. ...
3
votes
How can I add Google MarkerClusterer library to Smart Map?
UPDATE
It looks like the underlying MarkerClusterer library has been moved (and theoretically improved).
The new library can be found here...
https://github.com/googlemaps/js-markerclustererplus
Not ...
2
votes
Why do the plugin resource paths include the localization prefix?
When Craft generates a “resource URL” from a front-end request, it just takes whatever the current site URL is, adds the resourceTrigger config setting (“cpresources”), and then adds the path that was ...
2
votes
Accepted
Why do the plugin resource paths include the localization prefix?
Good question... As far as I know, the plugin's resource paths should not include the localization prefix. The resources are being called via PHP in the most direct way possible:
craft()->...
2
votes
Accepted
Filtering/Searching fields with enumerated data (e.g. Smart Map) in an ElementCriteria model
UPDATE
As of Smart Map 2.3.0, this is now possible!
https://plugins.doublesecretagency.com/smart-map/filtering-entries-by-subfield-value/
ORIGINAL
Currently, this isn't possible. However, it's a ...
2
votes
Search Matrix and Smartmap
The syntax to set a custom field parameter on a Matrix Block element criteria model is like so:
{% set blocks = entry.myMatrixField.mySmartMapField(params) %}
2
votes
Accepted
SmartMap throwing back javascript error
There are actually two problems happening here...
(1) For a location to appear on a map, it's critical for the latitude & longitude to be filled in. Within the UX of the Address field, this can ...
2
votes
Accepted
How can I tell Smart Map to look at Commerce for entries?
You need to tell Craft to look within the Commerce section like this:
{% set entries = craft.commerce.products.address(params).order('distance').find() %}
2
votes
Smart Map Lat+Lng is present but no pin on map
As Craft defaults to only returning 100 elements, setting the limit(null) parameter to the query fixed this issue.
{% set locations = craft.users.group('fullMembership').limit(null) %}
2
votes
Accepted
Smart Map with multiple different markers based on a matrix field
I believe the problem is in this line of code:
var markerId = 'smartmap-mapcanvas-1.{{ entry.id }}.address';
Because you're generating markers from matrix blocks, you'll need to use the block ID ...
2
votes
Accepted
How do I add styles or a theme to a Smart Map map?
You'll need to add the styling via JavaScript...
smartMap.map['smartmap-mapcanvas-1'].setOptions({styles: styles});
This can't currently be done in Twig, although I may explore that option in the ...
2
votes
Accepted
Filter locations by zip in Smart Map
This turned out to be an issue with a misconfigured Google API key.
When setting up your Google API keys, make sure that:
Your domain is whitelisted (including any staging servers).
Your keys have ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
plugin-smartmap × 53craft3 × 5
templating × 5
google-maps × 5
plugins × 4
elementcriteriamodel × 4
matrix × 3
relations × 3
javascript × 3
custom-fieldtype × 2
plugin-googlemaps × 2
plugin-development × 1
localization × 1
search × 1
plugin-elementapi × 1
filter × 1
query × 1
pagination × 1
registration × 1
ordering × 1
elementquery × 1
group × 1
plugin-solspacecalendar × 1
output × 1
svg × 1