Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map fields disappearing after save #160

Closed
ljclark opened this issue May 8, 2019 · 13 comments
Closed

Map fields disappearing after save #160

ljclark opened this issue May 8, 2019 · 13 comments

Comments

@ljclark
Copy link

ljclark commented May 8, 2019

Description

The Map and it's associated fields (search, address etc) are present on a new entry. When you save the entry, it's saving the location and rendering the map on the front end as expected.

However, if you try and edit that map data in the entry again, none of the inputs for the map field are visible.

There's this error in the console when you try edit the entry which I'm assuming is related to this. All other fields are fine, its just the maps field that's breaking.

vendor.js:13 TypeError: Cannot read property '$on' of undefined
    at p.mounted (sidebar.js:9)
    at We (vendor.js:13)
    at Object.insert (vendor.js:13)
    at y (vendor.js:13)
    at Mo.__patch__ (vendor.js:13)
    at Mo.t._update (vendor.js:13)
    at Mo.n (vendor.js:13)
    at Xe.get (vendor.js:13)
    at new Xe (vendor.js:13)
    at vendor.js:13

Steps to reproduce

  1. Create an entry using the map field
  2. Save the entry
  3. Go back and edit the entry, and the Map fields won't be visible.

Additional info

  • Craft version: Craft Pro 3.1.25
  • Maps version: 3.4.11
  • PHP version: 7.1.20
  • Database driver & version: MySQL 5.5.62
  • Other Plugins - see screenshot below:

Screenshot 2019-05-08 at 21 33 37

@codeartaus
Copy link

I'm also getting this issue, as well as a 404 for the file /cpresources/2ed3d3ff/js/apifetch.js

Did you find a fix for this one?

@codeartaus
Copy link

I just found a fix for mine, it was another plugin causing a js error, that in turn was breaking the maps

@jacobgraf
Copy link

I am having this same issue and it's definitely a frustrating one. Is there a fix on the way?

@Tam
Copy link
Member

Tam commented Jun 13, 2019

@jacobgraf Do you share any of the plugins @ljclark listed? The likely cause seems to be that another plugin is interfering with Maps' JS.

@jacobgraf
Copy link

Only Redactor is common between us.

@elfacht
Copy link

elfacht commented Jun 24, 2019

@codeartaus Would you mind sharen the plugin with us which was causing the error?

@elfacht
Copy link

elfacht commented Jun 24, 2019

I'm getting this error:

You have included the Google Maps JavaScript API multiple times on this page. This may cause unexpected errors.

Saving an entry without entering a location into the maps field will break the output. So I have to re-enter the location on every save. Frustrating. Especially in combination with this issue: #165 (comment)

Edit:

The JS error is caused because of multiple includes in MapField.php

	// Map Services
// ---------------------------------------------------------------------

if (strpos($settings->mapTiles, 'google') !== false)
{
  $view->registerJsFile(
    'https://maps.googleapis.com/maps/api/js?libraries=places&key=' .
    $settings->mapToken
  );
}
elseif (strpos($settings->mapTiles, 'mapkit') !== false)
{
  $view->registerJsFile(
    'https://cdn.apple-mapkit.com/mk/5.x.x/mapkit.js'
  );
}

// Geo Services
// ---------------------------------------------------------------------

if ($settings->geoService === GeoEnum::GoogleMaps)
{
  $view->registerJsFile(
    'https://maps.googleapis.com/maps/api/js?libraries=places&key=' .
    $settings->geoToken
  );
}
elseif ($settings->geoService === GeoEnum::AppleMapKit)
{
  $view->registerJsFile(
    'https://cdn.apple-mapkit.com/mk/5.x.x/mapkit.js'
  );
}

Removing either will still work and eleminates the error, but the bug with the disappearing data will still occur.

And this seems to be why Mapbox doesn't work: it will be not included. I tried Mapbox with my API, but with no results.

Output with correct saving:

{
   "googlePlace":{
      "administrative_area_level_1":"Hamburg",
      "administrative_area_level_2":"",
      "administrative_area_level_3":"",
      "administrative_area_level_4":"",
      "administrative_area_level_5":"",
      "airport":"",
      "bus_station":"",
      "colloquial_area":"",
      "establishment":"",
      "floor":"",
      "intersection":"",
      "locality":"Hamburg",
      "natural_feature":"",
      "neighborhood":"",
      "park":"",
      "parking":"",
      "point_of_interest":"",
      "political":"",
      "post_box":"",
      "postal_code":"20259",
      "postal_code_prefix":"",
      "postal_town":"",
      "premise":"",
      "room":"",
      "route":"Osterstraße",
      "street_address":"",
      "street_number":"98",
      "sublocality":"",
      "sublocality_level_1":"Bezirk Eimsbüttel",
      "sublocality_level_2":"",
      "sublocality_level_3":"",
      "sublocality_level_4":"",
      "sublocality_level_5":"",
      "subpremise":"",
      "train_station":"",
      "transit_station":"",
      "administrative_area_level_1_short":"",
      "administrative_area_level_2_short":"",
      "administrative_area_level_3_short":"",
      "administrative_area_level_4_short":"",
      "administrative_area_level_5_short":"",
      "airport_short":"",
      "bus_station_short":"",
      "colloquial_area_short":"",
      "establishment_short":"",
      "floor_short":"",
      "intersection_short":"",
      "locality_short":"",
      "natural_feature_short":"",
      "neighborhood_short":"",
      "park_short":"",
      "parking_short":"",
      "point_of_interest_short":"",
      "political_short":"",
      "post_box_short":"",
      "postal_code_short":"",
      "postal_code_prefix_short":"",
      "postal_town_short":"",
      "premise_short":"",
      "room_short":"",
      "route_short":"",
      "street_address_short":"",
      "street_number_short":"",
      "sublocality_short":"",
      "sublocality_level_1_short":"",
      "sublocality_level_2_short":"",
      "sublocality_level_3_short":"",
      "sublocality_level_4_short":"",
      "sublocality_level_5_short":"",
      "subpremise_short":"",
      "train_station_short":"",
      "transit_station_short":"",
      "number":"98",
      "address":"Osterstraße, Bezirk Eimsbüttel",
      "city":"Hamburg",
      "postcode":"20259",
      "county":"",
      "state":"Hamburg",
      "country":"Deutschland"
   }
}

After re-saving:

{
   "googlePlace":{
      "number":"98",
      "address":"Osterstraße, Bezirk Eimsbüttel",
      "city":"Hamburg",
      "postcode":"20259",
      "county":"",
      "state":"Hamburg",
      "country":"Deutschland"
   }
}

@elfacht
Copy link

elfacht commented Jul 10, 2019

For me this bug disappears after updating Craft to 3.2

@jacobgraf
Copy link

Works fine in 3.2 for me too! 🎉

@elfacht
Copy link

elfacht commented Jul 15, 2019

Aaaaand it happens again after updating to 3.6.0

@ljclark
Copy link
Author

ljclark commented Jul 15, 2019

Upgrading to C3.2 and Maps 3.6 has made Maps complete unusable for me now. I don't even get the maps field or input on a brand new entry! Any update on this?

@dbig
Copy link

dbig commented Jul 18, 2019

Similar for me - a new install of SimpleMap 3.6 into C3.2.4.1 results in entered address not searching/saving. Empty address fields when entry opened after saving.

@Tam
Copy link
Member

Tam commented Jul 19, 2019

This should be fixed in 3.6.1.

@Tam Tam closed this as completed Jul 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants