Title: Funny problem with the map when adding locations per script
Last modified: August 21, 2016

---

# Funny problem with the map when adding locations per script

 *  Resolved [Statistiker](https://wordpress.org/support/users/statistiker/)
 * (@statistiker)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/funny-problem-with-the-map-when-adding-locations-per-script/)
 * 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/](http://wordpress.org/plugins/events-manager/)

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

 *  Thread Starter [Statistiker](https://wordpress.org/support/users/statistiker/)
 * (@statistiker)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/funny-problem-with-the-map-when-adding-locations-per-script/#post-4277654)
 * 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.
 *  [Philip John](https://wordpress.org/support/users/philipjohn/)
 * (@philipjohn)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/funny-problem-with-the-map-when-adding-locations-per-script/#post-4277687)
 * 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
 *  [igemini1](https://wordpress.org/support/users/igemini1/)
 * (@igemini1)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/funny-problem-with-the-map-when-adding-locations-per-script/#post-4277739)
 * Hello [@statistiker](https://wordpress.org/support/users/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/](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.

 * ![](https://ps.w.org/events-manager/assets/icon-256x256.png?rev=3550347)
 * [Events Manager - Calendar, Bookings, Tickets, and more!](https://wordpress.org/plugins/events-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/events-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/events-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/events-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/events-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/events-manager/reviews/)

## Tags

 * [manually](https://wordpress.org/support/topic-tag/manually/)
 * [xml](https://wordpress.org/support/topic-tag/xml/)

 * 3 replies
 * 3 participants
 * Last reply from: [igemini1](https://wordpress.org/support/users/igemini1/)
 * Last activity: [12 years, 7 months ago](https://wordpress.org/support/topic/funny-problem-with-the-map-when-adding-locations-per-script/#post-4277739)
 * Status: resolved