Skip Navigation

[Resuelto] Maps plugin – either address or lat long?

This support ticket is created hace 6 años, 11 meses. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

Etiquetado: 

Este tema contiene 4 respuestas, tiene 2 mensajes.

Última actualización por Geoffrey Cleverley hace 6 años, 11 meses.

Asistido por: Luo Yang.

Autor
Mensajes
#601776

Hey there,

From looking through the threads:
https://toolset.com/forums/topic/storage-location-of-latitudelongitude/
https://toolset.com/forums/topic/how-to-use-the-longitude-and-latitude-fields-in-a-view/
https://toolset.com/forums/topic/separating-content-from-the-address-field/

It seems that the Address field only stores the Address as a string or Lat/Long, and not both.

Is that still the case?

Problem is...

I am using the Map/Address field to store the addresses of venues.

But then on the front end, I am using a Javascript embed that needs lat/long passed to it, to display the Map on the venue page.

I don't want to have to ask the user to type in an address in one field to store the string, then do it again to store the Lat/Long for the Map embed.

Do you have any suggestions as to how best get around this, or any solutions you have found.

I am not using views or layouts, so I am not using shortcodes or anything else. I need to be able to get at this data with just php calls.

Thanks

Jeff

#601908

Dear Jeff,

I assume we are talking about a custom address field, the custom address field is stored in as a string, but the lat/long values is cached in the setting page:
https://toolset.com/documentation/user-guides/data-caching-for-google-maps-addresses/

And you can display the lat/long values with Types shortcode, for example:
[types field='my-address' format='FIELD_ADDRESS: FIELD_LATITUDE, FIELD_LONGITUDE'][/types]
https://toolset.com/documentation/customizing-sites-using-php/functions/#address

If you need the display it with PHP codes, please try withe the Types function types_render_field(), see our document:
https://toolset.com/documentation/customizing-sites-using-php/functions/

#602133
view_query_filter.png
view_template.png
post_edit.png
Output.png

Hey Luo,

Thanks for the assist.

So, since I am using the types beta I have been told I need to use the views beta anyway. Since that's the case I decided to go the shortcode route within a view and use render_view from the API.

https://toolset.com/documentation/user-guides/display-on-google-maps/
https://toolset.com/documentation/user-guides/maps-shortcodes/

I am using the new relationships.

https://toolset.com/documentation/programmer-reference/views-api/#render_view
In my single-event.php template file I am using the following to render out the view:

echo render_view( array( 'id' => 179 )  );

I have the following primary post types:

Events CPT - 'events' slug
Venues CPT - 'venues' slug

They are joined in a one to many relationship by the intermediary - Events at Venues - 'venues-events' slug

I have created a view (id 179) that queries 'venues' with the post relationship filter:

'selects posts in an Events at Venue relationship, that are related to the Post where this view is shown
(screenshot - view_query_filter)

In the Loop Wizard I've selected:

Venue Address is : [types field="venue-map-location"][/types]<br>
Venue Post ID is : [wpv-post-id]
[wpv-map-render map_id="map-6" map_height="400" single_zoom="16"][/wpv-map-render]
[wpv-map-marker map_id="map-6" marker_id="marker-[wpv-post-id]" marker_title="Uberdooze" marker_field="wpcf-venue-map-location"][/wpv-map-marker]

(Screenshot - view_template)

So I can see it is querying the correct venue post, as the address field is outputting correctly.
The post ID of the venue is displaying the correct ID (this was just for troubleshooting.
You can see this from the screenshot of the post edit, address and ID.
(Screenshot - post_edit)

But the map that is being outputted is not showing any marker at all and is showing a location in the middle of the sea.
(Screenshot - Output)

I am expecting that this is my own stupidity and I've missed something in the documentation, it would be grand if you could help point me in the right direction.

I've also made a duplicator as this site isn't live even on staging. It's actually a site/theme I'm looking to rewwork from using CMB2 to adapt to a better workflow for users that should become possible with the new relationships in the Types/Views beta.

Thanks again

Jeff

#602397

For the new question:
But the map that is being outputted is not showing any marker at all and is showing a location in the middle of the sea.

Please check these:
1) make sure you have already setup the google map API by following our document:
https://toolset.com/documentation/user-guides/display-on-google-maps/creating-a-google-maps-api-key/
2) When you insert the map marker shortcode into content, add debug="true" attribute, for example:
[wpv-map-marker debug="true" ... ] ... [/wpv-map-marker]
It will be able to output some useful debug information, copy them to this thread, we need to know if there is any error in your website.

3) deactivate other plugins and switch to wordpress default theme, and test again
4) If the problem still persists, please provide a database dump file of your website, I need to test and debug it in my localhost, thanks

#602410

Hey Luo,

I figured it out.

I'm in Shanghai and have been using an always on personal Shadowsocks server to navigate the GFW recently, so hadn't even thought about this. My localhost couldn't contact the API's. Unusually though, only the geocoding and places API.

Since I could contact the maps API, and also access my Google developer console, Google search, Gmail vi Desktop client etc I didn't assume this was a problem. As a last ditch before sending you a dump I also turned on my Astrill VPN client together with Shadowsocks and can now access all the API's required.

Thanks for your help, and have a great 2018.

Jeff