• Resolved Statistiker

    (@statistiker)


    Hi,

    so far I have found no script, which enables me to import an xml file to Events Manager. Therefore I have writte myself a small function which parses an xml file and inserts the data into the Events Manager table. Everything seems fine, but here comes the problem:

    I create a new location via:

    //create new EM_Location object
    $new_location = new EM_Location();
    $new_location->location_country = 'DE';//Typically my events are placed in Germany
    $new_location->location_town = 'Any Town you want';
    $new_location->location_address = 'Any address you want;
    $new_location->location_state = 'Any state you want';
    $new_location->location_name = 'Any Name you want';
    $new_location->location_postcode = 'Guess what any postcode you want;);
    
    //check if location already exists
    $EM_Locations = EM_Locations::get();
    $found_location = false;
    foreach($EM_Locations as $EM_Location){
    	if ($location == $EM_Location->name)
    	{
    		$found_location = true;
    		$new_location->id = $EM_Location->id;
    	}
    }
    
    if ($found_location == false)
       $new_location->save();

    Now if I insert real values for address etc. the location is correctly inserted into wordpress and everything works except the map. The Map is unfortunatly not loaded. Now I tried to leave one field blank and inserted the value on my own. This time the map is created, but only if I insert one value manually.

    Can anyone give me a hint?

    Thanks in advance!

    Statistiker

    http://wordpress.org/plugins/events-manager/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Statistiker

    (@statistiker)

    So I found the problem. Unfortunately I don’t only have to provide a name, address and a country but also the coordinates (latitude and longitude) to get a working map.

    Yep, that sounds right.

    When you add a location through the dashboard, Javascript is used to load the location on a map as you type the address out and the lat/lon is pulled from that.

    So EM expects there to be a Lat/Lon as well as an address always.

    Cheers,
    Phil

    Hello @statistiker,

    I have no problem getting the maps without adding the coordinates, just the address. Using a Google Maps plugin does it. This is a premium plugin and here is the link: http://premium.wpmudev.org/project/wordpress-google-maps-plugin/

    Best,
    igemini

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Funny problem with the map when adding locations per script’ is closed to new replies.