gebeer Posted August 1, 2016 Share Posted August 1, 2016 @mr-fan if you are still having the problem from with geocoding from your custom fields, maybe my modified InputfieldLeafletMapMarker.js gist can help. I have a custom button in the form that triggers the geocoding, defined on line 48 and a fucntion from line 135 that takes values from custom fields, concats them and does the geocoding. 3 Link to comment Share on other sites More sharing options...
mr-fan Posted August 1, 2016 Share Posted August 1, 2016 Thanks i will test asap. Thanks to netcarver - great addition! Link to comment Share on other sites More sharing options...
ceberlin Posted August 2, 2016 Share Posted August 2, 2016 I tried this on localhost with a new project. I getting errors in the backend and the map space is white. Propbably because I am running the backend in https: http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css - Works https://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css - Works not (Firefox security - Invalid certificate) They advise a different CDN on their homepage, that's maybe why: Quote Using a Hosted Version of Leaflet The latest stable Leaflet release is hosted on a CDN — to start using it straight away, place this in the head of your HTML code: <link rel="stylesheet" href="https://npmcdn.com/leaflet@0.7.7/dist/leaflet.css" /> <script src="https://npmcdn.com/leaflet@0.7.7/dist/leaflet.js"></script> or <link rel="stylesheet" href="https://npmcdn.com/leaflet@1.0.0-rc.2/dist/leaflet.css" /> <script src="https://npmcdn.com/leaflet@1.0.0-rc.2/dist/leaflet.js"></script> Link to comment Share on other sites More sharing options...
Beluga Posted August 2, 2016 Share Posted August 2, 2016 Did anyone try with 1.0 latest rc? http://leafletjs.com/2016/07/16/leaflet-1.0-rc2.html Link to comment Share on other sites More sharing options...
netcarver Posted August 2, 2016 Share Posted August 2, 2016 @ceberlin Could you describe a little more about which version you are trying - Mats', gebeer's or the one I posted? I did have some trouble initially with getting the Leaflet related files in the right place. Having a script blocker running also broke things for me - once I enabled all JS on my local site things started working a lot better. @Beluga I haven't tried that version - yet. Can't speak for Mats or gebeer. See below. Link to comment Share on other sites More sharing options...
netcarver Posted August 2, 2016 Share Posted August 2, 2016 @Beluga I just pushed a new leaflet-v1.0.0rc2 branch to my repo - works nicely. @ceberlin If you were referring to my work above, please try out the v1.0.0rc2 branch as it pulls the files in from the npmcdn you referenced in your quote. 2 Link to comment Share on other sites More sharing options...
Beluga Posted August 2, 2016 Share Posted August 2, 2016 41 minutes ago, netcarver said: @Beluga I just pushed a new leaflet-v1.0.0rc2 branch to my repo - works nicely. Nice one! Did you guys know that LibreOffice Online uses Leaflet to render the interface tiles? Link to comment Share on other sites More sharing options...
ceberlin Posted August 3, 2016 Share Posted August 3, 2016 @netcarver This fixed it! 1 Link to comment Share on other sites More sharing options...
netcarver Posted August 3, 2016 Share Posted August 3, 2016 @ceberlin Great to hear that. I've switched my master branch over to Leaflet 0.7.7 from the npmcdn links you posted above. Could you try out the files from the master branch? Link to comment Share on other sites More sharing options...
Juergen Posted August 3, 2016 Share Posted August 3, 2016 Thanks for this awesome module!!! Question: is it possible to remove loading the FontAwesome CSS from the LeafletMapHeaderLines (fe. at the options)? I use FontAwesome on a website and this will lead to that it will be loaded twice. Best regards Link to comment Share on other sites More sharing options...
netcarver Posted August 3, 2016 Share Posted August 3, 2016 @Juergen If you pull the latest version of my master branch you'll be able to exclude the FontAwesome css file by doing the following: <?php echo $map->getLeafletMapHeaderLines(false); ?> Edited to add: Actually, you can just replace your copy of MarkupLeafletMap.module with the new one from the repository. 2 Link to comment Share on other sites More sharing options...
Juergen Posted August 4, 2016 Share Posted August 4, 2016 Thanks! I will try this out. Link to comment Share on other sites More sharing options...
ceberlin Posted August 4, 2016 Share Posted August 4, 2016 15 hours ago, netcarver said: I've switched my master branch over to Leaflet 0.7.7 from the npmcdn links you posted above. Could you try out the files from the master branch? @netcarver Now works well with the standard setup here. Does not work with the HERE map series (I think to remember the v100rc2 beta does). 2 Link to comment Share on other sites More sharing options...
netcarver Posted August 4, 2016 Share Posted August 4, 2016 @ceberlin Thanks for checking that out. Regarding the HERE map series - I'm seeing the same here. Link to comment Share on other sites More sharing options...
Juergen Posted August 6, 2016 Share Posted August 6, 2016 On 1.8.2016 at 6:05 PM, gebeer said: I have a custom button in the form that triggers the geocoding, defined on line 48 and a fucntion from line 135 that takes values from custom fields, concats them and does the geocoding. It would be great to add this to the module with the opportunity to select if you want to use it or not (in the field settings). Link to comment Share on other sites More sharing options...
Reid Bramblett Posted August 23, 2016 Share Posted August 23, 2016 This may seem simplistic, but how do I make a map where existing fields on the pages define the marker settings? In other words, rather than creating separate new fields on the page template for marker_icon and marker_color (and then laboriously having to fill them in each time), how I can use an existing field, and then merely provide some code denoting the corresponding changes I would like to the marker options. For example, for a travel site, each page has a "category" field (sleep, eat, see), and I would like that field to automatically determine the marker color and icon (anything with a category=sleep has marker_color = orange and marker_icon = bed, that sort of thing). I got this working on individual pages with "if" statements, but can't seem to get this working within the array needed to populate a map drawing from lots of pages. Thanks! Link to comment Share on other sites More sharing options...
netcarver Posted August 23, 2016 Share Posted August 23, 2016 5 hours ago, Reid Bramblett said: For example, for a travel site, each page has a "category" field (sleep, eat, see), and I would like that field to automatically determine the marker color and icon (anything with a category=sleep has marker_color = orange and marker_icon = bed, that sort of thing). Hi Reid, Give this a shot. It's a template file that should do what you want if you are using my fork of the Leaflet module. <!DOCTYPE html><?php // Create our Leaflet map object. We do it here, before the header output, so we can use it to generate includes in the // header itself. $map = $modules->get('MarkupLeafletMap'); ?> <html lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title><?php echo $page->title; ?></title> <link rel="stylesheet" type="text/css" href="<?php echo $config->urls->templates?>styles/main.css" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <?php echo $map->getLeafletMapHeaderLines(); ?> </head> <body> <h1><?php echo $page->title; ?></h1> <?php // Extract the pages that will be turned into markers on the map $items = $pages->find("<YOUR SELECTOR HERE>"); // Update as needed // Setup the options for our map $map_options = array( // This routine formats the marker icon that gets used on the map. 'markerFormatter' => function ($page, $marker_options) { switch ($page->category) { // Update with the fieldname you wish to check as needed // For sleep category markers case 'sleep' : $marker_options['icon'] = 'bed'; $marker_options['markerColor'] = 'orange'; break; // Add other cases as needed // Here's the default marker setup default : $marker_options['icon'] = 'cutlery'; $marker_options['markerColor'] = 'blue'; break; } return $marker_options; } ); // Generate the HTML and JS that will render the map with a marker for each page in the $items page array echo $map->render($items, '<YOUR MAP MARKER FIELDNAME HERE>', $map_options); // Update as needed ?> </body> </html> Please be aware that the icon colours you can choose from are pretty limited. Look at the 'markerColor' row in the table here for your options. Hope that helps. Link to comment Share on other sites More sharing options...
Reid Bramblett Posted August 23, 2016 Share Posted August 23, 2016 Beauty, Netcarver. Just the ticket. (And I had already resigned myself to working with leaflet's limited color palette to approximate the color scheme I'm using on the site.) Thanks so much for this. Does in a few lines of code what used to take me ages to create by hand. Loving it. Link to comment Share on other sites More sharing options...
netcarver Posted August 23, 2016 Share Posted August 23, 2016 @Reid Bramblett Glad that worked out for you. @Mats Thanks for pulling our changes back into your repository - great! I made a few little tweaks to my repo since you did the merge; any chance of getting them pulled over to your repo as well? >PS Nice change to your avatar! I like the look of those T-shirts 3 Link to comment Share on other sites More sharing options...
Mats Posted August 24, 2016 Author Share Posted August 24, 2016 @netcarver Repo is updated. Thats's my favourite shirt! Thanks for setting up the store. 2 Link to comment Share on other sites More sharing options...
jploch Posted August 25, 2016 Share Posted August 25, 2016 Hey guys! I have a problem with this. When I put the <?php echo $map->getLeafletMapHeaderLines(); ?> in the header of my template a get a Error: Call to a member function getLeafletMapHeaderLines() on a non-object (line 34 of /www/htdocs/w00dd152/projekte/fabricius/site/templates/_header.php) I have checkt the permissons on the module files, everything is on 777. I also pressed the reload button (as suggested) on the module page in PW but still no luck. Iam running PW 3.0.30 devns Link to comment Share on other sites More sharing options...
flydev Posted August 25, 2016 Share Posted August 25, 2016 @jploch before calling the function, call the module : <?php $map = $modules->get('MarkupLeafletMap'); echo $map->getLeafletMapHeaderLines(); ?> 2 Link to comment Share on other sites More sharing options...
jploch Posted August 25, 2016 Share Posted August 25, 2016 thx! I just figured this out, when reading the documentation, I must have missed it. Link to comment Share on other sites More sharing options...
jploch Posted August 25, 2016 Share Posted August 25, 2016 is there a trick, when using this with a repeater for multible markers in PW 3? Here is my code, but thats not working: <?php $lage = wire('pages')->get("/lage/"); $items = $lage->map_repeater; echo $map->render($items, 'map'); ?> Also in the backend, the Address field is not clickable, when I use the Map Field in a Repeater Edit: It seems that the files for the module are not loading. I get an error in the console that the files are not loading. Link to comment Share on other sites More sharing options...
netcarver Posted August 25, 2016 Share Posted August 25, 2016 @jploch I've never used this in a repeater setup and I'm unsure of your field/template structure from that snippet. How have you actually structured things? What's the field called that holds the map markers? Regarding the backend, the address is normally a read-only field that is set either by clicking on the magnifying glass in the top-right corner of the map and entering a description or by simply dragging the marker around. Have you tried moving the marker or using the search feature? If they don't work, it is possible there is a problem with some of the JS not loading properly. Please could you launch you browser dev tools and see if any of the JS assets are not loading. 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