mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
MDL-34959 add Google Maps API V3 support
This commit is contained in:
parent
b32ec7a3b9
commit
cec7d43591
4 changed files with 36 additions and 3 deletions
|
@ -80,7 +80,7 @@ $PAGE->set_title(get_string('iplookup', 'admin').': '.$title);
|
|||
$PAGE->set_heading($title);
|
||||
echo $OUTPUT->header();
|
||||
|
||||
if (empty($CFG->googlemapkey)) {
|
||||
if (empty($CFG->googlemapkey) and empty($CFG->googlemapkey3)) {
|
||||
$imgwidth = 620;
|
||||
$imgheight = 310;
|
||||
$dotwidth = 18;
|
||||
|
@ -95,11 +95,23 @@ if (empty($CFG->googlemapkey)) {
|
|||
echo '</div>';
|
||||
echo '<div id="note">'.$info['note'].'</div>';
|
||||
|
||||
} else {
|
||||
} else if (empty($CFG->googlemapkey3)) {
|
||||
$PAGE->requires->js(new moodle_url("http://maps.google.com/maps?file=api&v=2&key=$CFG->googlemapkey"));
|
||||
$module = array('name'=>'core_iplookup', 'fullpath'=>'/iplookup/module.js');
|
||||
$PAGE->requires->js_init_call('M.core_iplookup.init', array($info['latitude'], $info['longitude']), true, $module);
|
||||
|
||||
echo '<div id="map" style="width: 650px; height: 360px"></div>';
|
||||
echo '<div id="note">'.$info['note'].'</div>';
|
||||
|
||||
} else {
|
||||
if (strpos($CFG->wwwroot, 'https:') === 0) {
|
||||
$PAGE->requires->js(new moodle_url('https://maps.googleapis.com/maps/api/js', array('key'=>$CFG->googlemapkey3, 'sensor'=>'false')));
|
||||
} else {
|
||||
$PAGE->requires->js(new moodle_url('http://maps.googleapis.com/maps/api/js', array('key'=>$CFG->googlemapkey3, 'sensor'=>'false')));
|
||||
}
|
||||
$module = array('name'=>'core_iplookup', 'fullpath'=>'/iplookup/module.js');
|
||||
$PAGE->requires->js_init_call('M.core_iplookup.init3', array($info['latitude'], $info['longitude'], $ip), true, $module);
|
||||
|
||||
echo '<div id="map" style="width: 650px; height: 360px"></div>';
|
||||
echo '<div id="note">'.$info['note'].'</div>';
|
||||
}
|
||||
|
|
|
@ -41,3 +41,21 @@ M.core_iplookup.init = function(Y, latitude, longitude) {
|
|||
}, document.body);
|
||||
}
|
||||
};
|
||||
|
||||
M.core_iplookup.init3 = function(Y, latitude, longitude, ip) {
|
||||
var ipLatlng = new google.maps.LatLng(latitude, longitude);
|
||||
|
||||
var mapOptions = {
|
||||
center: ipLatlng,
|
||||
zoom: 6,
|
||||
mapTypeId: google.maps.MapTypeId.ROADMAP
|
||||
};
|
||||
|
||||
var map = new google.maps.Map(document.getElementById("map"), mapOptions);
|
||||
|
||||
var marker = new google.maps.Marker({
|
||||
position: ipLatlng,
|
||||
map: map,
|
||||
title: ip
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue