public function map($id) { $address = $this->address(); if ($this->lat != null && $this->long != null) { sp_google_maps_by_coords($id, strtok($address, ","), $this->lat, $this->long, $address, $this->postcode); } else { sp_google_maps_by_address($id, strtok($address, ","), $address, $this->postcode); } }
function sp_google_map_shortcode($atts = array()) { static $i; if (!$i) { $i = 0; } else { $i++; } $atts = shortcode_atts(array('title' => 'Map Pin', 'postcode' => '', 'address' => '', 'coords' => ''), $atts, 'google_map'); // if(!is_admin()) { if ($atts['coords'] && strpos($atts['coords'], ',')) { $coords = explode(',', $atts['coords']); sp_google_maps_by_coords("embeded-google-map-{$i}", $atts['title'], trim($coords[0]), trim($coords[1]), $atts['address'], $atts['postcode']); } elseif ($atts['postcode']) { sp_google_maps_by_address("embeded-google-map-{$i}", $atts['title'], $atts['address'], $atts['postcode']); } else { return; } // } wp_enqueue_script('google_maps'); return "<div class=\"sp-map-canvas\" id=\"embeded-google-map-{$i}\"></div>"; }
public function display_map() { if (!$this->postcode && !$this->long && !$this->lat) { return; } if ($this->lat != null && $this->long != null) { sp_google_maps_by_coords("map-canvas-group-{$this->id}", $this->title(), $this->lat, $this->long, $this->address(true, true), $this->postcode); } else { sp_google_maps_by_address("map-canvas-group-{$this->id}", $this->title(), $this->address(true, true), $this->postcode); } echo "<div class=\"sp-group-map-canvas\" id=\"map-canvas-group-{$this->id}\"></div>"; }