Jump to content

Module: Leaflet Map


Mats

Recommended Posts

On 5/19/2018 at 11:51 AM, patman said:

I just had a quick look, I think there is a bug in the render function at the end:


$this->page->inlineScript = $inlineScript;

 This would replace the page content always with the last map. Unfortunately, I was not quickly able to fix it. In my opinion adding a dot


$this->page->inlineScript .= $inlineScript;

should make it, but it didn't (at least in my quick try).

It seems to work for me!!! ???

God bless you patman! ?
Thank you.

Link to comment
Share on other sites

Hi

I'm using this great module to display points from a page list. I added a leafletmap field on page template and all is good. That's work !

But now, how can I remove geolocalized informations on some pages ?

For example: on a page I set a location to Paris in leafletmap field on the "france" page. Now I would like to delete this geographic information (lat, lng, address, zoom) to remove this point (location to Paris)... How can I do ? When a point is set, it seems to be impossible to delete it... Is there a solution ?

Thks in advance 

Link to comment
Share on other sites

  • 1 month later...
  • 5 weeks later...

I changed my site to https using the Let's encrypt certificate.

Therefore I uncommented the respective lines in the .htaccess.

But the leafletmap module doesn't seem to get this right and includes the css files in the head of the page with http only. So the page doesn't load because of mixed content.

Where can I fix this so as the https files become included?

Thanks for help.

Link to comment
Share on other sites

57 minutes ago, joe_ma said:

I changed my site to https using the Let's encrypt certificate.

Therefore I uncommented the respective lines in the .htaccess.

But the leafletmap module doesn't seem to get this right and includes the css files in the head of the page with http only. So the page doesn't load because of mixed content.

Where can I fix this so as the https files become included?

Thanks for help.

I don't use this module so maybe not the best person to respond, but it looks like it should load the https version. It was changed to this in this commit: https://github.com/madebymats/FieldtypeLeafletMapMarker/commit/eb0c1e703a0b3eb5bc6c00aaee44eb59a6d22dfe#diff-b979b991c53396a5160add7bfa0c8dcb

 

Link to comment
Share on other sites

42 minutes ago, adrian said:

Totally OT, but is there any reason this module loads 0.7.3 of leaflet when they are up to 1.3.4?

I think the reason is just lack of time on the part of the module devs, but it would also need to be adapted because of breaking changes. I have been thinking of giving another shot at debugging this thoroughly, but have lacked time and energy.

  • Like 2
Link to comment
Share on other sites

Thanks Adrian

I changed all these lines and now it works. Sort of.

But:
the leaflet.js script that is now loaded still contains links to unsecure sites. I get the following errors/warning:

Quote

Gemischte (unsichere) Anzeige-Inhalte von "http://c.tiles.wmflabs.org/bw-mapnik/18/136622/92145.png" werden auf einer sicheren Seite geladen. leaflet.js:7:7263

 

Link to comment
Share on other sites

2 minutes ago, joe_ma said:

Thanks Adrian

I changed all these lines and now it works. Sort of.

But:
the leaflet.js script that is now loaded still contains links to unsecure sites. I get the following errors/warning:

 

Perhaps you can just grab a copy of leaflet.js and serve it up locally. Then you can edit it to replace those http calls with https

Link to comment
Share on other sites

  • 3 weeks later...
On 8/29/2018 at 8:23 PM, Beluga said:

I think the reason is just lack of time on the part of the module devs, but it would also need to be adapted because of breaking changes. I have been thinking of giving another shot at debugging this thoroughly, but have lacked time and energy.

Bah, this was my own blunder: I had failed to include leaflet.awesome-markers.css when I made my attempt to bump those versions. I had also overlooked that the readme has $map->getLeafletMapHeaderLines(); that should be echoed to our head element (the readme in Github is hard to read, so copying to a text editor helped).

With this in mind I modified the getLeafletMapHeaderLines function MarkupLeafletMap.module like so to get all the latest hotness:

$lines .= <<<LINES
<!-- Styles supporting the use of Leaflet.js -->
<link rel="stylesheet" type="text/css" href="https://unpkg.com/leaflet@1.3.4/dist/leaflet.css" />
<link rel="stylesheet" type="text/css" href="https://unpkg.com/leaflet.markercluster@1.4.1/dist/MarkerCluster.css" />
<link rel="stylesheet" type="text/css" href="https://unpkg.com/leaflet.markercluster@1.4.1/dist/MarkerCluster.Default.css" />

<!-- Scripts supporting the use of Leaflet.js -->
<script type="text/javascript" src="https://unpkg.com/leaflet@1.3.4/dist/leaflet.js"></script>
<script type="text/javascript" src="https://unpkg.com/leaflet.markercluster@1.4.1/dist/leaflet.markercluster.js"></script>
<script type="text/javascript" src="https://unpkg.com/leaflet-providers@1.4.0/leaflet-providers.js"></script>
<script type="text/javascript" src="{$url}MarkupLeafletMap.js"></script>

<!-- Extend Leaflet with Awesome.Markers -->
<link rel="stylesheet" type="text/css" href="https://unpkg.com/drmonty-leaflet-awesome-markers@2.0.2/css/leaflet.awesome-markers.css" />
<script type="text/javascript" src="https://unpkg.com/drmonty-leaflet-awesome-markers@2.0.2/js/leaflet.awesome-markers.js"></script>

 

Link to comment
Share on other sites

  • 3 weeks later...

I would like to replace the Ryan's original MarkupGoogleMap with this module. I installed this MarkupLeafletMap and tried to change the Map Marker fieldtype to Leaflet Map Marker. But it seems these fieldtypes are not compatible with each other. 

What should I do to change the old field with its over 200 pages to use this fieldtype?

Link to comment
Share on other sites

Hi everybody! And thanks for Processwire!

The Leaflet Map module appears to have the same issue that the gmap-based Map Marker Map module. The map will not render if placed inside ajax-driven repeater item as one of its data fields because there's no leaflet map initialization after the ajax call. Here's a small fix to be added at the bottom of InputfieldLeafletMapMarker.js file:

//A patch for displaying the map inside ajax repeater items
	$(".InputfieldHeader").on('click',function(event) {
			window.setTimeout(function(){
				var $t = $(event.target).siblings('.InputfieldContent').find('.InputfieldLeafletMapMarkerMap');
				InputfieldLeafletMapMarker.init($t.attr('id'), $t.attr('data-lat'), $t.attr('data-lng'), $t.attr('data-zoom'), $t.attr('data-type'), $t.attr('data-provider'));
			},500);
		});
	});

The delay is rather arbitrary, 500 ms works for me.

  • Like 3
Link to comment
Share on other sites

  • 5 weeks later...
  • 4 weeks later...

A quick query on this module if anyone might be able to shed some light. I have a staging site running PW 3.0.61 and version 2.8.1 of this module, but in the field settings page I'm getting a "Error geocoding address" message.

I also have a local version of the same site, running PW 3.0.98 and version 3.0.3 of the module (from the latest branch on Github – upgrading in the PW admin didn't seem to give the latest version), giving the exact same error. Nothing seems to be being blocked from executing.

I also have another two sites using different versions of PW and the module, and they're all working perfectly – I can't see any difference in the way they're set-up.

There's a console error as well:

Source map error: request failed with status 404
Resource URL: http://xxxxxx/wire/templates-admin/styles/AdminTheme.css?v=14k
Source Map URL: AdminTheme.css.map[Learn More]

Link to comment
Share on other sites

For the PW 3.0.61 site, make sure you use the PW3 branch on github.  Maybe that is why it isn't working properly?

I believe the console error you are getting about the source map missing has been fixed in Processwire.  Upgrade Processwire to the latest dev release and that error should go away.

Link to comment
Share on other sites

16 hours ago, gmclelland said:

For the PW 3.0.61 site, make sure you use the PW3 branch on github.  Maybe that is why it isn't working properly?

1

Sorry, I meant to put something else as well and forgot. To clarify:

On the two sites I'm looking at/comparing – 

 

Site 1  –  live site is PW 3.0.61 with module 2.8.1, local is PW 3.0.98 with module 3.0.2

Site 2 – live site is PW 3.0.62 with module 3.0.2, local is PW 3.0.98 with module 3.0.2

For site 1 the leaflet module works perfectly on live and local, site 2 the module doesn't work on either, even though the local site versions are exactly the same.

Hopefully that's a bit clearer.

Link to comment
Share on other sites

@Mats - something strange is happening when I upgrade the module from 3.0.2 to 3.0.3 using Processwire's Upgrade module.  When I try to upgrade the module, it goes from 3.0.2 to 2.8.1 instead of 3.03.

I wonder if you need to update the module's version or branch on processwire.com modules directory?

If I manually download the github version on the PW3 branch, I get 3.0.3 which is the correct version.

@houseofdeadleg - Maybe you could try geocoding that same address on the site that is working to make sure it isn't something wrong with the address itself?

I would recommend upgrading those sites that are on 3.0.61 and 62.  There has been many changes and bugs fixed since then.  Using the Processwire Upgrade module makes it easy to upgrade.  Sorry, I'm not sure what else the problem could be?

Link to comment
Share on other sites

I'm thinking to switch from Google Maps to Leaflet Maps to avoid adding payment details on Google but on the readme of this module says:

Quote

Google maps geocoding is still used for geocoding default lat/lng values under field settings but the geocoding on page editing uses Per Liedmans [leaflet-control-geocoder] (https://github.com/perliedman/leaflet-control-geocoder)

So I'm confused! Does this module needs a Google Geocoding API key in order to work or not???

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...