PWaddict Posted February 6, 2017 Share Posted February 6, 2017 1 hour ago, bernhard said: yes, it is: https://www.google.com/search?q=change google map colours should be very easy using their readymade styles: https://snazzymaps.com/ Yeah I know it's possible. I've already did on a map without using this module. I should be more specific. On a map without using this module I used this js to change the colors: var styles = [ { "stylers": [ { "hue": "#c1d72e" } ] } ]; So the proper question is how can I apply the above code on a map using this module? Link to comment Share on other sites More sharing options...
bernhard Posted February 6, 2017 Share Posted February 6, 2017 just don't use the modules render() method and write the code on your own. you should know how to do that as you say you already did it without the module you have all the necessary field data in these variables: echo $page->map->address; // outputs the address you entered echo $page->map->lat; // outputs the latitude echo $page->map->lng; // outputs the longitude echo $page->map->zoom; // outputs the zoom level you can also just copy the generated markup of your render method and then adjust the necessary (parts of your) scripts. Link to comment Share on other sites More sharing options...
PWaddict Posted February 6, 2017 Share Posted February 6, 2017 2 hours ago, bernhard said: just don't use the modules render() method and write the code on your own. you should know how to do that as you say you already did it without the module you have all the necessary field data in these variables: echo $page->map->address; // outputs the address you entered echo $page->map->lat; // outputs the latitude echo $page->map->lng; // outputs the longitude echo $page->map->zoom; // outputs the zoom level you can also just copy the generated markup of your render method and then adjust the necessary (parts of your) scripts. I've copied my code from an older website I've created a map with changed colors without using the module and it doesn't even load the map on the website I'm currently developing. It's driving me crazy... window.onload = function () { var latlng = new google.maps.LatLng(12.3456789, 12.3456789); var styles = [ { "stylers": [ { "hue": "#c1d72e" } ] } ]; var myOptions = { zoom: 17, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP, disableDefaultUI: true, styles: styles }; map = new google.maps.Map(document.getElementById('map'), myOptions); var myCenter = new google.maps.LatLng(12.3456789, 12.3456789); var myIcon = new google.maps.MarkerImage( "https://chart.googleapis.com/chart?chst=d_map_pin_letter&chld=%E2%80%A2|c1d72e", new google.maps.Size(24,30), new google.maps.Point(0,0), new google.maps.Point(12,23) ); var marker = new google.maps.Marker({position: myCenter, icon: myIcon, map: map}); On the 2nd method you proposed I don't know how to apply the code to change the color. If anyone managed to change the colors with this module PLEASE let me know how you dit it. Thanks. Link to comment Share on other sites More sharing options...
bernhard Posted February 6, 2017 Share Posted February 6, 2017 i would suggest doing the following: create a new template file for your page that holds the map data with exactly the code from the google example (javascript + html): https://developers.google.com/maps/documentation/javascript/examples/map-simple?hl=de change nothing but your api-key. when you view this page you should see the same map as on the google docs page. replace the fixed values for lat/lng/zoom by those saved in your processwire site. see my example above ($page->map->lat...) view your page, it should show the map at the position that you specified in your backend change your style by adding the styles options (see code below) view your page, you should see the new style if everything works, try to implement your map in your original template file var map; function initMap() { map = new google.maps.Map(document.getElementById('map'), { center: {lat: -34.397, lng: 150.644}, zoom: 8, // add comma here styles: [ { "stylers": [ { "hue": "#c1d72e" } ] } ] }); } 3 Link to comment Share on other sites More sharing options...
PWaddict Posted February 7, 2017 Share Posted February 7, 2017 14 hours ago, bernhard said: i would suggest doing the following: create a new template file for your page that holds the map data with exactly the code from the google example (javascript + html): https://developers.google.com/maps/documentation/javascript/examples/map-simple?hl=de change nothing but your api-key. when you view this page you should see the same map as on the google docs page. replace the fixed values for lat/lng/zoom by those saved in your processwire site. see my example above ($page->map->lat...) view your page, it should show the map at the position that you specified in your backend change your style by adding the styles options (see code below) view your page, you should see the new style if everything works, try to implement your map in your original template file var map; function initMap() { map = new google.maps.Map(document.getElementById('map'), { center: {lat: -34.397, lng: 150.644}, zoom: 8, // add comma here styles: [ { "stylers": [ { "hue": "#c1d72e" } ] } ] }); } Thanks to your suggestions I finally figured out the problem. I had to replace the % on map's css to px. Link to comment Share on other sites More sharing options...
webhoes Posted February 7, 2017 Share Posted February 7, 2017 I have the big map working with this code (quite basic) $items = $page->children; $map = $modules->get('MarkupGoogleMap'); $content .= $map->render($items, 'map'); For the page with turtles I want to have the current turtle on that page to be visible on the map. I have made the following code: if($page->hasChildren) { $results = $page->children("limit=9, sort=-created"); $pagination = $results->renderPager(); $content .= $pagination; $content .= renderSchildpadden($results); $content .= $pagination; } foreach ($results as $result){ foreach ($result->verspreidingen as $verspreiding) { $out .= $verspreiding . "|"; } } //$item = $out; $sidebar_bottom = $out; $map = $modules->get('MarkupGoogleMap'); $sidebar_bottom .= $map->render($out, 'map'); The part for the sidebar_bottom gives the following error: Error: Uncaught Error: Call to a member function first() on string in /home/deb26781n3/domains/chrysemys.nl/public_html/site/modules/FieldtypeMapMarker/MarkupGoogleMap.module:209 Stack trace: #0 /home/deb26781n3/domains/chrysemys.nl/public_html/site/templates/schildpadden.php(32): MarkupGoogleMap->render('1213|1198|1199|...', 'map') #1 /home/deb26781n3/domains/chrysemys.nl/public_html/wire/core/TemplateFile.php(268): require('/home/deb26781n...') #2 [internal function]: ProcessWire\TemplateFile->___render() #3 /home/deb26781n3/domains/chrysemys.nl/public_html/wire/core/Wire.php(374): call_user_func_array(Array, Array) #4 /home/deb26781n3/domains/chrysemys.nl/public_html/wire/core/WireHooks.php(549): ProcessWire\Wire->_callMethod('___render', Array) #5 /home/deb26781n3/domains/chrysemys.nl/public_html/wire/core/Wire.php(399): ProcessWire\WireHooks->runHooks(Object(ProcessWire\TemplateFile), 'render', Array) #6 /home/deb26781n3/domains/chrysemys.nl/public_html/wire/modules/PageRender.mod (line 209 of /home/deb26781n3/domains/chrysemys.nl/public_html/site/modules/FieldtypeMapMarker/MarkupGoogleMap.module) This error message was shown because: you are logged in as a Superuser. Error has been logged. The input for the big map are the pages that contain the field 'map'. foreach ($results as $result) { foreach ($result->verspreidingen as $verspreiding) { $out .= $verspreiding . "|"; } } The code above produces also an array of pages that contain the field 'map'. But this time the same function strugles on this part of the code in the module: if($options['useMarkerSettings'] && (count($pageArray) == 1 || !$lat)) { // single marker overrides lat, lng and zoom settings $marker = $pageArray->first()->get($fieldName); << this line and on first() returns the error $lat = $marker->lat; $lng = $marker->lng; if($marker->zoom > 0) $zoom = (int) $marker->zoom; } What am I doing wrong here? Sanne Link to comment Share on other sites More sharing options...
Robin S Posted February 7, 2017 Share Posted February 7, 2017 Not sure if this is the cause of the problem, but this line... if($options['useMarkerSettings'] && (count($pageArray) == 1 || !$lat)) { ...does not ensure that $pageArray exists. The if() condition is passed if $options['useMarkerSettings'] and !$lat, regardless of what $pageArray is. 1 Link to comment Share on other sites More sharing options...
webhoes Posted February 7, 2017 Share Posted February 7, 2017 I understand, but why does it work on page where I select children (array) but not on a page where I select certain pages as array that are the pages that have the 'map' field. An array is made on both occasions. The second array has duplicate items, could that be an issue? Sanne Link to comment Share on other sites More sharing options...
Robin S Posted February 7, 2017 Share Posted February 7, 2017 3 minutes ago, webhoes said: I understand, but why does it work on page where I select children (array) but not on a page where I select certain pages as array that are the pages that have the 'map' field. An array is made on both occasions. Not sure - nowhere in the code you posted do you show where $pageArray is defined. Quote Uncaught Error: Call to a member function first() on string What this error means is that $pageArray is a string and not an actual PageArray. Use Tracy to dump $pageArray and find out what is going on with it. Link to comment Share on other sites More sharing options...
webhoes Posted February 9, 2017 Share Posted February 9, 2017 (edited) @Robin S, yes it is a string. Also it is build upon repeating pagearray which doesn't lead to an correct new array. 1 | 2 | 3 | 4 2 | 5 | 8 5 | 4 | 5... The 2 in 4 2 is the start of an new array, so is the 5 in 8 5. It can't find something with 42 or 85. It seems the output has to be made a new array explicitly and also with the correct setup. Tried that yesterday, could not get it figured out. Edited February 9, 2017 by webhoes Link to comment Share on other sites More sharing options...
Robin S Posted February 9, 2017 Share Posted February 9, 2017 3 hours ago, webhoes said: yes it is a string. Also it is build upon repeating pagearray which doesn't lead to an correct new array. Strings and arrays are different types of data, and a PageArray is a actually an object but you can think of it as a special kind of array. Long story short, you can't use PageArray methods on a string. It's difficult to help without seeing the code where you set the $pageArray variable. Link to comment Share on other sites More sharing options...
rastographics Posted February 24, 2017 Share Posted February 24, 2017 I've been using Map Marker field with great success. I may have come across a strange bug, I'm not sure how to debug it... When using the value Elgin, IL in the Address field, the geocode fetches correctly, BUT after saving the page, the Address field is BLANK. I can do Elgin, Il (lowercase "L"), or Elgin, Illinois or South Elgin, IL or pretty much anything else I can think of, and everything WORKS. WHY is the Address field not getting saved with just Elgin, IL? Or how can I debug this (where to look?) Thanks Link to comment Share on other sites More sharing options...
Robin S Posted February 24, 2017 Share Posted February 24, 2017 43 minutes ago, rastographics said: When using the value Elgin, IL in the Address field, the geocode fetches correctly, BUT after saving the page, the Address field is BLANK. Not sure why that is happening, but just to let you know that address works fine for me. Could some browser extension be interfering perhaps? Link to comment Share on other sites More sharing options...
rastographics Posted February 24, 2017 Share Posted February 24, 2017 Good idea, but unfortunately I just tried incognito mode with all extensions off and still not working. No JS errors in console. Is there some other thing I can do to trace this down? Link to comment Share on other sites More sharing options...
swampmusic Posted March 4, 2017 Share Posted March 4, 2017 On 10/7/2016 at 11:51 PM, bee8bit said: @adrian Thank you, that was not the right solution. But it made me investigate in the right place: InputfieldMapMarker's init function is never called. At the bottom, InputfieldMapMarker.js says: $(document).ready(function() { $(".InputfieldMapMarkerMap").each(function() { var $t = $(this); InputfieldMapMarker.init($t.attr('id'), $t.attr('data-lat'), $t.attr('data-lng'), $t.attr('data-zoom'), $t.attr('data-type')); }); }); When the $(document) is ready() there are no $(".InputfieldMapMarkerMap")s yet, as they will be AJAX-loaded later. So I guess we need an event that is fired after each successful AJAX call, so we can InputfieldMapMarker.init() all those Maps which haven't been initialized before. Is there a way to register a listener for such events? Hi @bee8bit. Did you find a solution or work around for this ? I have a similar issue. "Days, Location, Description" in a Repeater. Where Location was going to be a inputFieldMapMarker. But, obviously not working. Did you figure a work around based on event listener or something ? Regards, Link to comment Share on other sites More sharing options...
Arcturus Posted June 1, 2017 Share Posted June 1, 2017 I'm having an issue in PW 3.0.62 where the module will only geocode an address when I manually click the checkmark between address and lat/lng off/on when editing the page within the admin. Based on what I've read here, it seems only the client-side geocoder is working? Additional details: I have both Google Maps and Google Places APIs working without issue on the front-end and have added my Maps key to the module's configuration My MapMarker-based field, "map", has a MapMarker: Error geocoding address notification and I can't find any elaboration Neither API has any issues with my address formatting/default address, with an example being 5 Bloor Street, Toronto, ON M4W 3T3 My addresses are mapping properly when I play with the checkbox (status goes from UNKNOWN to OK) I can't trigger the geocoding via the API Any ideas? Link to comment Share on other sites More sharing options...
Jozsef Posted June 18, 2017 Share Posted June 18, 2017 On 1/6/2017 at 10:45 PM, Arcturus said: MapMarker: Error geocoding address The same issue. Running PW 3.0.61 and Map Marker 2.0.6 worked just fine. After upgrading to 2.0.9 and entering my API key I get the above error to any address I try. Link to comment Share on other sites More sharing options...
elabx Posted June 26, 2017 Share Posted June 26, 2017 On a map I setup, I had the trouble of encoded (ampersend made me notice) characters not getting output decoded correctly, so I had to add htmlspecialchars_decode on this this line: $title = $options['markerTitleField'] ? htmlspecialchars_decode($page->get($options['markerTitleField'])) : ''; Shouldn't this be the expected behaviour? And why is the page title getting output without decoded entities? Is this expected inside modules for security reasons? Just trying to learn some PW here Link to comment Share on other sites More sharing options...
mel47 Posted August 1, 2017 Share Posted August 1, 2017 Hi I'm trying to display a map with a marker on frontend with this : $map = $modules->get('MarkupGoogleMap'); $content.= $map->render($page->children, 'map'); The map appear, correctly zoomed at the good location. However there is no marker. The marker appear correctly in backend. Do I miss something? Thanks Mélanie PW 3.0.69 - MapMarker 2.0.9 Link to comment Share on other sites More sharing options...
Kiwi Chris Posted September 11, 2017 Share Posted September 11, 2017 The basic functionality of the module is great, but I wanted the capacity to add paths, and potentially geometric areas, and the easiest way I found to generate them was using something like Google Earth, or various mobile GPS apps which export KML files. KML files can contain map markers as well, but the module already handles these fine. The Google Maps API allows adding KML layers, and of course Processwire already has a files fieldtype, so it's easy to create a files field that only allows files of type kml. I had to make a few modifications to the FieldTypeMapMarker as well. MarkupGoogleMap.js //Add support for KML overlays, eg exported from Google Earth, or various GPS apps. this.addKml = function (url) { var zIndex = 99999 + this.numMarkers + 1; var layerOptions = { url: url, map: this.map, zIndex: zIndex } var kml = new google.maps.KmlLayer(layerOptions); } MarkupGoogleMap.module I added a 'postinit' property that is output after the map has been rendered. I found that the overlays can only be added after the map has been initialised, so the existing 'init' property didn't work. Here's how I used it in a template: $map = $modules->get('MarkupGoogleMap'); foreach ($page->kml as $kmlFile) { $overlays .= "mgmap1.addKml('$kmlFile->httpUrl'); "; } $content .= $map->render($page, 'location', array('type' => 'ROADMAP', 'postinit' => $overlays)); The code could probably be improved to have the foreach loop inside MarkupGoogleMap.module, and just pass the name of the overlay field if any, but it needs to be optional, as not all maps will have an associated field with kml files. 2 Link to comment Share on other sites More sharing options...
PWaddict Posted September 24, 2017 Share Posted September 24, 2017 To always display the map at the center even if the browser resized or the full screen button pressed just use the below function: google.maps.event.addDomListener(window, 'resize', function() { var center = map.getCenter() google.maps.event.trigger(map, "resize") map.setCenter(center) }); Link to comment Share on other sites More sharing options...
thmsnhl Posted October 20, 2017 Share Posted October 20, 2017 (edited) Edit: I just realized there are 18 Pages in this thread and I am pretty sure someone else mentioned it, I will have a look I have just added the module to a new site I am creating and it seems like there are some issues. 1. The API key is not recognized when using the <script>-tag from module page (<script type='text/javascript' src='https://maps.googleapis.com/maps/api/js?sensor=false'></script>) – I had to add <script src="https://maps.googleapis.com/maps/api/js?libraries=places&key={{my API key}}"></script> in order to display the map. 2. The map in frontend does not look like the one in the backend. Instead of green areas for parks I get an all grey version, as you can see on the screenshots below. Has anyone else noticed this? PW Version is ProcessWire 3.0.62 from stable channel. Edited October 20, 2017 by thmsnhl 1 Link to comment Share on other sites More sharing options...
joer80 Posted November 8, 2017 Share Posted November 8, 2017 On 10/20/2017 at 4:42 AM, thmsnhl said: Edit: I just realized there are 18 Pages in this thread and I am pretty sure someone else mentioned it, I will have a look I have just added the module to a new site I am creating and it seems like there are some issues. 1. The API key is not recognized when using the <script>-tag from module page (<script type='text/javascript' src='https://maps.googleapis.com/maps/api/js?sensor=false'></script>) – I had to add <script src="https://maps.googleapis.com/maps/api/js?libraries=places&key={{my API key}}"></script> in order to display the map. 2. The map in frontend does not look like the one in the backend. Instead of green areas for parks I get an all grey version, as you can see on the screenshots below. Has anyone else noticed this? PW Version is ProcessWire 3.0.62 from stable channel. I had to do this as well! Link to comment Share on other sites More sharing options...
gar1606 Posted November 30, 2017 Share Posted November 30, 2017 And the answer to the different maps on Frontend/Backend was? Link to comment Share on other sites More sharing options...
gar1606 Posted December 1, 2017 Share Posted December 1, 2017 so I am using this module and it is working great, I figured out that it doesn't render properly in collapse. But now I want to disable or reset what happens when you click on an map marker or icon. I don't want to pass it a url, I want it to href to an id on the same page and I just don't seem to get it, where do I set the url or replace it. Thank you Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now