Jump to content

Map Marker Map


ryan

Recommended Posts

On 5/14/2020 at 12:50 PM, Mamun Paul said:

The site I'm working on was already upgraded to 2.8. Is the Map maker only compatible for the processwire 3.0.148?

I've upgraded Processwire from 2.8 to 3.0.0.148 and also upgraded map marker module to 2.0.9 
Still on the admin  sub location maps are not visible on page load on chrome. Need to double click then it appears.
While on Mozilla it works fine.
Why this is happening?

Link to comment
Share on other sites

 After upgrade to Processwire 3.0.148 there is an issue with map markers.
The map sometimes appears all in grey and one has to click on the location pin to have the map appear.
The + and - zoom buttons are also missing and appear only when clicking full screen.

Skärmavbild_2020-04-15_kl._21.03.08.png

Link to comment
Share on other sites

Do you have the latest version of the Googles map marker module?
There was an issue with hidden elements (looks like the map is in a repeater field) although it should be fixed in the latest version: https://github.com/ryancramerdesign/FieldtypeMapMarker/pull/2

There is a Leaflet version of this module: https://modules.processwire.com/modules/fieldtype-leaflet-map-marker/.
Don't know if it will solve your issue though.

 

Link to comment
Share on other sites

On 6/5/2020 at 11:23 PM, Mats said:

Do you have the latest version of the Googles map marker module?
There was an issue with hidden elements (looks like the map is in a repeater field) although it should be fixed in the latest version: https://github.com/ryancramerdesign/FieldtypeMapMarker/pull/2

There is a Leaflet version of this module: https://modules.processwire.com/modules/fieldtype-leaflet-map-marker/.
Don't know if it will solve your issue though.

 

Hello @Mats

I've installed https://modules.processwire.com/modules/fieldtype-leaflet-map-marker/.
I'm still facing the same issue of sub location map not visible.
This issue is only in chrome on double click the map appers while in mozila it works fine.
Do you know why it is happening?

Thanks in advance!
 

Link to comment
Share on other sites

  • 2 months later...
  • 1 month later...

Hi!  I'm experimenting with Ryan's RCDmap.js... got it all working but just wanted to use SVG images for the map markers. There's no class I can get... and #map .svg doesn't work. It seems like there should be a way in defining the icons to add something similar to 

    iconSize: [30,30]

or google's map options:

      size: new google.maps.Size(71, 71),
      origin: new google.maps.Point(0, 0),
      anchor: new google.maps.Point(17, 34),
      scaledSize: new google.maps.Size(25, 25)

     Not having much luck... and yes, I can do very tiny png images but they are tend to get blurry on higher res devices. Not sure whether I should just try leaflet maps instead.

 

   /* The path to the icons folder */
        var path = '/site/templates/icons/';
        var marker = new google.maps.Marker({
            position: latLng,
            map: RCDMap.map,
            icon: path + cat + '.svg'

        });
 

 

 

mapmarker.png

Link to comment
Share on other sites

  • 5 months later...

Google allows to restrict API keys, but you can only restrict to URLs (useful for showing maps) or IP-addresses (useful for geocoding with PHP). I tested the inputfield using API keys with one of the restrictions each and one with no restrictions. The (expected) result:

  • key restricted only to URL: Map in the inputfield works, geocoding with hitting enter (not clicking outside the field before) works
  • key restricted to IP: Map does not work, but server-side geocoding (with PHP on save) works
  • key with no restrictions (not recommended!): everything works

So I think, there should be two fields for the configuration in the module: one for a server-side key and one for a frontend key (also used fro the inputfiled map). Or do I get something wrong?

Something else I noticed: In InputfieldMapMarker.module on line 79 and in MarkupGoogleMap.module on line 161 I think the domain should be googleapis.com instead of google.com

  • Like 1
Link to comment
Share on other sites

  • 5 months later...
On 3/15/2021 at 2:12 PM, TheMick said:

Google allows to restrict API keys, but you can only restrict to URLs (useful for showing maps) or IP-addresses (useful for geocoding with PHP). I tested the inputfield using API keys with one of the restrictions each and one with no restrictions. The (expected) result:

  • key restricted only to URL: Map in the inputfield works, geocoding with hitting enter (not clicking outside the field before) works
  • key restricted to IP: Map does not work, but server-side geocoding (with PHP on save) works
  • key with no restrictions (not recommended!): everything works

So I think, there should be two fields for the configuration in the module: one for a server-side key and one for a frontend key (also used fro the inputfiled map). Or do I get something wrong?

Something else I noticed: In InputfieldMapMarker.module on line 79 and in MarkupGoogleMap.module on line 161 I think the domain should be googleapis.com instead of google.com

I'm just using this module for the first time in a while and finding similar behaviour (Google Cloud has change a lot since I last used this module).

I haven't tested the scenarios as thoroughly as @TheMick however I can confirm that everything works without the API key restriction, however restricting it by IP or Http referrer in GC dashboard generates a 'Error geocoding address' response and the lat/long fields don't populate.

Link to comment
Share on other sites

4 hours ago, Guy Incognito said:

I'm just using this module for the first time in a while and finding similar behaviour (Google Cloud has change a lot since I last used this module).

I haven't tested the scenarios as thoroughly as @TheMick however I can confirm that everything works without the API key restriction, however restricting it by IP or Http referrer in GC dashboard generates a 'Error geocoding address' response and the lat/long fields don't populate.

I looked into this further. I tweaked the module to dump out the response from Google API and it confirms that indeed referrer restricted API keys won't work with the Geocode API.

Array ( [error_message] => API keys with referer restrictions cannot be used with this API. [results] => Array ( ) [status] => REQUEST_DENIED )

 

Link to comment
Share on other sites

20 hours ago, Guy Incognito said:

I looked into this further. I tweaked the module to dump out the response from Google API and it confirms that indeed referrer restricted API keys won't work with the Geocode API.

Array ( [error_message] => API keys with referer restrictions cannot be used with this API. [results] => Array ( ) [status] => REQUEST_DENIED )

 

Hey @Guy Incognito, hey all

I've struggled with the same error message, but found a solution: Make sure that you've enabled both API's the "Maps JavaScript API" & the "Geocoding API" .

1524705482_2021-08-2018_15_43.jpg.933fca2454ecd22e3395d78e9f2f2fca.jpg

Also make sure to add the wildcards in the restriction settings like so:

https://example.com/*
https://www.example.com/*
http://example.com/*
http://www.example.com/*

Hope this'll help a little bit. Greets!

Link to comment
Share on other sites

35 minutes ago, DV-JF said:

Hey @Guy Incognito, hey all

I've struggled with the same error message, but found a solution: Make sure that you've enabled both API's the "Maps JavaScript API" & the "Geocoding API" .

1524705482_2021-08-2018_15_43.jpg.933fca2454ecd22e3395d78e9f2f2fca.jpg

Also make sure to add the wildcards in the restriction settings like so:

https://example.com/*
https://www.example.com/*
http://example.com/*
http://www.example.com/*

Hope this'll help a little bit. Greets!

Hi @DV-JF - I'm pretty sure I do have both these enabled but I will check thanks. I have found that IP restriction works fine for my requirements though after all - turns out that my server was reporting an IPv6 IP and not the IPv4 I had set in the restrictions. 🙈 So back up and running for now 😊

Link to comment
Share on other sites

  • 2 months later...

Is there any way to prevent this module from deleting the address entered in the field after the page has been saved?

I love that the latitude and longitude is created and saved on page reload, but it would be nice to have a reference of what those coordinates are for by keeping the contents of the address field.

Link to comment
Share on other sites

10 minutes ago, HMCB said:

Is there any way to prevent this module from deleting the address entered in the field after the page has been saved?

Never mind. After I entered a different address than the one entered in the field set-up, things are working just fine.

Link to comment
Share on other sites

  • 4 months later...

I would like to iterate through PW pages and grab the coordinates (that FieldtypeMapMarker created on saving the page) and display those multiple markers in __one__ map. I would love to have a module that does that, but I don’t see that in the PW module directory.

Has anyone done anything like this in a PW project?

I did a little research and found this from Google: https://googlemaps.github.io/js-markerclusterer/

It appears to ingest a JSON file for the marker locations.

Edited by kongondo
moderator note: Merged your thread to FieldtypeMapMarker's support thread.
Link to comment
Share on other sites

As those mapmarker details are saved within those fields for any page, you could just query them.

echo $page->yourMapMarkerField->address;	// outputs the address you entered
echo $page->yourMapMarkerField->lat; 		// outputs the latitude
echo $page->yourMapMarkerField->lng; 		// outputs the longitude
echo $page->yourMapMarkerField->zoom;		// outputs the zoom level

https://processwire.com/modules/fieldtype-map-marker/

And from there you could pass it on to your template to build a custom map.

<?php namespace ProcessWire;

$mapitems = $pages->find("template=yourTemplateWithMapMarkers");
$options = array(
   'markerIcon' => 'fa-icon', // your custom icon
   'markerColour' => 'color', // your custom color
   'height' => '100%',
   'zoom' => '12',
   'scrollWheelZoom' => 'false',
   'useStyles' => 'false',
   'popupFormatter' => function ($page) {
       $lines = array();
       $lines[] = "$page->street";
       $lines[] = "$page->postalcode $page->city";
       return implode("<br />", $lines);
   }

);
?>

That's what I use with the LeafletMapMarker Module (a fork of Map Marker for Google)

Which then results in this (see bottom of that page):
https://www.restaurants-neumuenster.de/restaurants/

  • Like 1
Link to comment
Share on other sites

On 3/2/2022 at 6:49 PM, wbmnfktr said:

That's what I use with the LeafletMapMarker Module (a fork of Map Marker for Google)

Which then results in this (see bottom of that page):
https://www.restaurants-neumuenster.de/restaurants/

That map is very nice. I’ll keep Leaflet in mind for my next improvement to my app. Thank you, as I see how some of that code you posted would be beneficial.

Turns out MapMarker can’t be used in FormBuilder, which I didn’t realize. I wanted to use it for capturing coordinates as entries were saved. So instead, I ended up using a PHP script that I tailored to my needs. In PW, I queried and saved all the addresses (right now about 10–12, eventually up to 30) to an array. I then passed that array to Google’s GeoCoder API and let it do the hard work (parsing the address) instead of me having to figure out latitude and longitude. It works well and loads fast.

I’m not a developer but thanks to helpful answers by everyone in this community, I’m able to learn as I go.

  • Like 1
Link to comment
Share on other sites

  • 2 months later...

For some reason this map marker field has stopped working on my production server. It just saves 0.00000 as both lat and lng values, even though it correctly finds and shows the lat/lng on the field itself.

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...