Steps to reproduce:

  • Set a view with the Geolocation Commonmap format
  • Choose the "Provide fixed latitude and longitude." option
  • Set a lat/lng that is not the center of your displayed nodes' scope, but an extreme point for your set or somewhere outside your nodes' scope
  • Save and check your view
  • The map is not centered on the fixed lat and lng

It seems that even when using this setting, the last googleMap.fitBounds(bounds); in geolocation-common-map.js resets the center to fit all the points on the map. Commenting out that line allows to enforce the fixed lat/lng.

Comments

juliencarnot created an issue. See original summary.

juliencarnot’s picture

Reproduced with latest dev version, including the new way of setting the center induced by 2625952 (in both first row and fixed modes).

christianadamski’s picture

Originally the fixed centre point was included in the set of bound positions, so it would at least be present. Not sure if that is true anymore. Definitely not the centre anyway after the fitBounds() call.

The problem I don't get around yet is, that the zoom is static. Right now fixing the map centre with a static zoom value, makes it basically pure luck if the locations fit to the map or not.

If you have the time: https://developers.google.com/maps/documentation/javascript/reference which of these functions seems the most appropriate? panToBounds() sounds quite good. Set the fixed centre value on the map and than call that function on the bounds. Yes/no/maybe?

juliencarnot’s picture

Ok, I guess I didn't understand the feature correctly. My current use case might sound a bit strange, but I want to display a specific area at a certain zoom level, like an excerpt of the content. Some locations from elsewhere are not initially displayed, but are shown if one zooms out and move to their area (I managed to do that by altering the geolocation-common-map.js file to set a center and a zoom level)

So here's what I was expecting:

  • First row: center on the first marker, no fitBounds, some locations may not be displayed in the "viewport"
  • Fixed: center on the latlng provided, no fitBounds, some locations may not be displayed in the "viewport"
  • Relying on fitBounds only: all locations in the view should fit on the displayed map, zoom adjusts to the locations.

I was wondering why the zoom couldn't be set in the GUI for the two first options, and overridden for the last one, but it makes more sense if fitBounds was to be used in each scenario.

What I don't really get then is how the first row option would be different from a fitBounds on every location including that one, and in which scenario you would set a fixed "center" outside of the area of your locations but still intend to display all of them...

As a matter of fact, I don't really have an opinion about the fitBounds alternatives, it worked well when I tried to use it, adjusting the viewport and displaying all locations.

Hope this comment makes some sense to you, sorry for my misunderstanding!

christianadamski’s picture

Status: Active » Needs review
StatusFileSize
new15.25 KB

Please test.

Status: Needs review » Needs work

The last submitted patch, 5: 2661022-5-respect-common-map-settings-correctly.patch, failed testing.

The last submitted patch, 5: 2661022-5-respect-common-map-settings-correctly.patch, failed testing.

The last submitted patch, 5: 2661022-5-respect-common-map-settings-correctly.patch, failed testing.

The last submitted patch, 5: 2661022-5-respect-common-map-settings-correctly.patch, failed testing.

The last submitted patch, 5: 2661022-5-respect-common-map-settings-correctly.patch, failed testing.

christianadamski’s picture

Status: Needs work » Needs review
StatusFileSize
new16.07 KB

Fixed test view

juliencarnot’s picture

Thanks, this is great!

Some remarks:

  • An alert shows when displaying a view with fitbounds ;-)
  • A notice appears in the logs:
    Location 	https://172.17.0.3/admin/structure/views/ajax/display/ressources/page_1/style_options?_wrapper_format=drupal_ajax
    Referrer 	https://172.17.0.3/admin/structure/views/view/ressources
    Message 	Notice: Undefined index: zoom in Drupal\geolocation\Plugin\views\style\CommonMap->buildOptionsForm() (line 335 of /var/www/html/modules/geolocation/src/Plugin/views/style/CommonMap.php).
    Severity 	Notice
  • Haven't tested the 27 combinations ;-), but if the first checked option supersedes the others, are there some cases that would be left behind if we go back to a dropdown list instead of the checkboxes choice?
  • Not sure if this is a limitation of Views, but these style settings apply to all displays of a view. Could it be superseded for one view, like other parameters are? It could be nice to have set a block with a zoomed-in map and a page with a global map fitting all markers for the same view, instead of having to duplicate the view and having to replicate subsequent changes in two separate views...
christianadamski’s picture

  1. removed alert()
  2. explicitly check if settings/zoom is set
  3. my idea is, that the single options are aligned as a fall back. If one options for whatever reason doesn't work, use the next one
  4. I actually jumped some hoops to at least theoretically allow for several different view maps to be displayed on the same page. That does not work?
juliencarnot’s picture

  1. OK
  2. OK
  3. OK, makes sense!
  4. I don't think it's working: there's no dropdown list with "All displays (except overridden)", "This page (override)", "Revert to default" as in the Add field modal window for example and when I save a change for the block display, it changes the page display too...

Thanks again!

christianadamski’s picture

4. The override option is with the selection of the Format (=style), not its setting. I have the "This display" choice when I click the "Geolocation - CommonMap" instead of "Settings"

Can you confirm that?

juliencarnot’s picture

Ok, really sorry about that! I was wrongly assuming that the "This display" choice on the "Geolocation - CommonMap" modal was only impacting that modal and not the settings modal! Thanks!

christianadamski’s picture

Well, it's a bit much to ask you that, but, does it actually work? I did not yet get around to test that and already getting occupied with new work. can you test that? Like, create a page and two attachments with both commonmap styles but different settings? Does that actually work? PHP wise and JS wise?

juliencarnot’s picture

Yes, I created a page view with commonmap and included a block from the same view with commonmap, both with different settings and they coexist happily! Thanks so much!

christianadamski’s picture

Status: Needs review » Reviewed & tested by the community

Thank you! :)

I guess this is RTBC than...

Maybe Jochen will also test one more time to be sure.

derjochenmeyer’s picture

Version: 8.x-1.4 » 8.x-1.x-dev
Status: Reviewed & tested by the community » Needs review
StatusFileSize
new19.72 KB

Thanks! Any reason to use centre instead of center in some places?

derjochenmeyer’s picture

StatusFileSize
new11.13 KB

Here's an interdiff

christianadamski’s picture

http://grammarist.com/spelling/center-centre/

I'm just THAT sophisticated...

But seriously, I don't care either way.

  • derjochenmeyer committed 57c548c on 8.x-1.x
    Issue #2661022 by ChristianAdamski, derjochenmeyer: Common map - using...
derjochenmeyer’s picture

Status: Needs review » Fixed

Well we need to discuss that ,-)

No seriously, I just wanted to get the git attribution.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.