-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get data out of geocoding #10
Comments
the trick is to realize that each map field can have a number of different markers in it.. assuming you just have one marker in the map field it would be something like this {% set options = { id: 'map', width: '400px', height: '300px' } %} {% for marker in entry.yourCustomMapField.getMarkers() %} {{ craft.googleMaps.center('map',lat, lng) }} Iif you just want to output the map for an entry is to use the field directly so just this, and it will automatically center on that marker {% set options = { id: 'map', width: '400px', height: '300px' } %} |
Is this list of variables documented somewhere "marker.lat" and "marker.lng"? |
I dont think they are fully documented yet. I just went into the plugin files, in "models" theres GoogleMaps_MarkerModel and GoogleMaps_MapDataModel. in both of those look for the "defineAttributes()" function that will list the properties of the model |
ahh and he also has it written out in the wiki although there appears to be a typo as it says latitude vs lat |
Got it. I'll look there. Thank you! Was pulling my hair out yesterday trying to accomplish what I needed to accomplish for this project. Still having weird issues. |
When I try this code on a location's detail page with my custom field name added, I get no output.
Do you? |
yup… is map your map fields handle? Have you turned on geocoding ? Geocoding has to be enabled in the plugin settings and you note which fields make up the address to geocode or on the field settings if you want it to geocode it as you edit the entry. |
Yes, "map" is my field's handle. GeoCoding is on in plugin settings and I'm running the latest version #0.7.1 The fields that make up the address are set at the plugin level and the field level and the entry's marker is correctly set and saved in the DB. I can get the map to show up on the detail page using this code but I want to control the zoom level and cannot do that using map() or data():
|
just use the zoom settings https://github.com/objectivehtml/Google-Maps-for-Craft/wiki/Template-Reference#zoom so add this {{ craft.googleMaps.zoom('locationmap', 12) }} |
I have tried that code and every other possible way to control the zoom. That code doesn't override the maps default zoom at all for me. What works is setting "fitBounds: false" on map()... but then I need to get the marker's lat and long in order to center and zoom the map out... hence my question about how you get data out of the "geocoding'. Will keep trying. |
NOTE: I can get lat & lng printing out in the template if I move the variables inside the for loop:
|
ALAS... This finally worked!
Keith, a sincere THANK YOU! |
Yup, thanks the way to do it. Thanks for the help Keith. Out of town on vacation this week with limited access to Internet. |
I'm struggling to understand this part...
I have the address for each of my store locations geocoded. How do I get pieces of data out in the template?
For example, if I want to center my map (https://github.com/objectivehtml/Google-Maps-for-Craft/wiki/Set-Map-Center) and use the lat & long stored in the geocoding... how would I do that?
The code example on that page is:
{{ craft.googleMaps.center('map', 40, -86) }}
How do I get 40 and -86 to fill with the lat/long from the geocoding?
The text was updated successfully, but these errors were encountered: