Answer the question
In order to leave comments, you need to log in
How to center a marker on the map on click without reloading the page?
The site has a plugin for creating maps. This page has a map with two links above it. Clicking on each of the links centers the marker with a specific id and sets the desired zoom level, which is specified in the URL.
The problem is that on click, the page reloads along with the action, and I just need to execute a script that would center a certain marker, open an info window and set the desired zoom level. There is another plugin that can create beautiful animated buttons, to which you can attach not only a URL, but also custom JS. Tell me, what needs to be done so that it is possible to set the centering of a certain marker and the zoom level in the buttons without reloading the page?
I don't understand Java Script at all, and the file is very large, I hope that I pulled out the correct piece of code that is responsible for processing links:
function wpgmza_getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
vars[key] = value;
});
return vars;
}
var wpgmza_open_marker = wpgmza_getUrlVars()["markerid"];
var wpgmza_open_marker_zoom = wpgmza_getUrlVars()["mzoom"];
/* do they want to open a marker from a GET variable? */
if (typeof wpgmza_open_marker !== "underfined") {
if (wpgmza_open_marker === wpmgza_marker_id) {
infoWindow[wpmgza_marker_id].setOptions({maxWidth:wpgmaps_localize_global_settings['wpgmza_settings_infowindow_width']});
infoWindow[wpmgza_marker_id].setContent(html);
infoWindow[wpmgza_marker_id].open(MYMAP[map_id].map, marker);
MYMAP[map_id].map.setCenter(point);
if (typeof wpgmza_open_marker_zoom !== "undefined") {
MYMAP[map_id].map.setZoom(parseInt(wpgmza_open_marker_zoom));
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question