rvalitov / widgetkit-map-ex

Responsive version of Yootheme's Map Widget (Widgetkit2) with center map point and advanced features
GNU General Public License v3.0
22 stars 3 forks source link

getWidgetkitMap function to return null #71

Closed GordonBreazz closed 6 years ago

GordonBreazz commented 6 years ago

System information

CMS type: WordPress

CMS version: 4.9.4 plugin version: v1.5.8

Why getWidgetkitMap function to return null?

Simple code

<script>

  var PageLoaded = false;
  //alert('ok');
  window.onload = function() {
    PageLoaded = true;
    console.log('ok');
    var map_id=jQuery('#my_map>div').attr('id');
    console.log(map_id);       
    var map_object = getWidgetkitMap(map_id);
    map_object.setZoom(8);
    console.log(map_id); 
  }
</script>
rvalitov commented 6 years ago

Thank you for reporting this. I confirm this problem, it seems it appeared in one of the last versions of the widget. I will fix it soon.

rvalitov commented 6 years ago

The problem happened, because you called the function too early, when the Google Map object has not been initialized yet because of async script loading. I fixed this problem in v1.5.9 which is available for download. Please, check the manual, it has been updated: https://github.com/rvalitov/widgetkit-map-ex/wiki/Working-with-Google-Map-object-(for-Javascript-programmers)

If you will face any other problems, please, let me know.

GordonBreazz commented 6 years ago

Thank you very much for your kind help and support. Let me ask you a few questions.

I'm creating a map similar to this http://www.bibliogorod.ru/libraries.

Thanks in advance for your help.

rvalitov commented 6 years ago

The widget provides only a simple method for accessing the internal Google Map object. But I think that it's not enough to achieve your goal. The answer to all your questions is probably "no". Well, actually it may be possible, but will require lots of JavaScript programming and this approach is not efficient. It's better to improve the widget itself with PHP. In this case it's possible to add the functionality you need.

I'm available as a freelancer, and can make a special version of this widget for you, if needed. I speak Russian, and you can contact me directly by email ramilvalitov@gmail.com in case you're interested in this.

GordonBreazz commented 6 years ago

Thanks for the answer.