tried implemanting googlemap but failed for now
This commit is contained in:
@@ -12,15 +12,32 @@ Version: 1.0.0
|
||||
Author URI:
|
||||
*/
|
||||
|
||||
$markers = array("two");
|
||||
// if bock theme : https://wordpress.org/support/topic/twenty-twenty-two-cpt-template-error-theme-without-header-is-deprecated/
|
||||
function add_map_api(){
|
||||
?>
|
||||
<script type="text/javascript" src="https://www.openstreetmap.org/openlayers/OpenStreetMap.js"></script>
|
||||
<script type="text/javascript" defer>
|
||||
//<![CDATA[
|
||||
import Map from 'ol/Map';
|
||||
import View from 'ol/View';
|
||||
import OSM from 'ol/source/OSM';
|
||||
import TileLayer from 'ol/layer/Tile';
|
||||
|
||||
add_action('draft_to_publish', 'add_marker');
|
||||
|
||||
function add_marker(){
|
||||
array_push($markers, "one");
|
||||
new Map({
|
||||
layers: [
|
||||
new TileLayer({source: new OSM()}),
|
||||
],
|
||||
view: new View({
|
||||
center: [0, 0],
|
||||
zoom: 2,
|
||||
}),
|
||||
target: 'map',
|
||||
});
|
||||
//]]>
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
add_action('the_content', 'print_content', 1);
|
||||
add_action('wp_head', 'add_map_api');
|
||||
|
||||
function print_content($content){
|
||||
|
||||
@@ -73,7 +90,9 @@ function print_content($content){
|
||||
// $content .= "</p>";
|
||||
//}
|
||||
|
||||
//$content .= "<div id='map'><p>OSM map 2</p></div>";
|
||||
return $content;
|
||||
};
|
||||
add_action('the_content', 'print_content', 1);
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user