-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use @angular/compiler-cli instead of webpack for dist build
- Loading branch information
Showing
39 changed files
with
365 additions
and
628 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { setGeoCtrl } from './controls/GeoControl'; | ||
import { setScaleCtrl } from './controls/ScaleControl'; | ||
import { setOverviewMapCtrl } from './controls/OverviewMapControl'; | ||
import { setNavigationCtrl } from './controls/NavigationControl'; | ||
export var reCenter = function (map, opts) { | ||
var BMap = window['BMap']; | ||
if (opts.center) { | ||
map.setCenter(new BMap.Point(opts.center.longitude, opts.center.latitude)); | ||
} | ||
}; | ||
export var reZoom = function (map, opts) { | ||
if (opts.zoom) { | ||
map.setZoom(opts.zoom); | ||
} | ||
}; | ||
export var createInstance = function (opts, element) { | ||
var BMap = window['BMap']; | ||
// create map instance | ||
var map = new BMap.Map(element); | ||
// init map, set central location and zoom level | ||
map.centerAndZoom(new BMap.Point(opts.center.longitude, opts.center.latitude), opts.zoom); | ||
setNavigationCtrl(map, opts); | ||
setScaleCtrl(map, opts); | ||
setOverviewMapCtrl(map, opts); | ||
if (opts.enableScrollWheelZoom) { | ||
//enable scroll wheel zoom | ||
map.enableScrollWheelZoom(); | ||
} | ||
setGeoCtrl(map, opts); | ||
return map; | ||
}; | ||
export var createMarker = function (marker, pt) { | ||
var BMap = window['BMap']; | ||
var opts = {}; | ||
if (marker.icon) { | ||
var icon = new BMap.Icon(marker.icon, new BMap.Size(marker.width, marker.height)); | ||
opts['icon'] = icon; | ||
} | ||
if (marker.enableDragging) { | ||
opts['enableDragging'] = true; | ||
} | ||
return new BMap.Marker(pt, opts); | ||
}; | ||
export var redrawMarkers = function (map, previousMarkers, opts) { | ||
var BMap = window['BMap']; | ||
var self = this; | ||
previousMarkers.forEach(function (_a) { | ||
var marker = _a.marker, listeners = _a.listeners; | ||
listeners.forEach(function (listener) { marker.removeEventListener('click', listener); }); | ||
map.removeOverlay(marker); | ||
}); | ||
previousMarkers.length = 0; | ||
if (!opts.markers) { | ||
return; | ||
} | ||
opts.markers.forEach(function (marker) { | ||
var marker2 = createMarker(marker, new BMap.Point(marker.longitude, marker.latitude)); | ||
// add marker to the map | ||
map.addOverlay(marker2); | ||
var previousMarker = { marker: marker2, listeners: [] }; | ||
previousMarkers.push(previousMarker); | ||
var onMarkerClickedListener = function () { | ||
self.onMarkerClicked.emit(marker2); | ||
}; | ||
marker2.addEventListener('click', onMarkerClickedListener); | ||
previousMarker.listeners.push(onMarkerClickedListener); | ||
if (!marker.title && !marker.content) { | ||
return; | ||
} | ||
var msg = "<p>" + (marker.title || '') + "</p><p>" + (marker.content || '') + "</p>"; | ||
var infoWindow2 = new BMap.InfoWindow(msg, { | ||
enableMessage: !!marker.enableMessage | ||
}); | ||
if (marker.autoDisplayInfoWindow) { | ||
marker2.openInfoWindow(infoWindow2); | ||
} | ||
var openInfoWindowListener = function () { | ||
this.openInfoWindow(infoWindow2); | ||
}; | ||
previousMarker.listeners.push(openInfoWindowListener); | ||
marker2.addEventListener('click', openInfoWindowListener); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{"reCenter":{"__symbolic":"error","message":"Function call not supported","line":8,"character":24},"reZoom":{"__symbolic":"error","message":"Function call not supported","line":15,"character":22},"createInstance":{"__symbolic":"error","message":"Function call not supported","line":21,"character":30},"createMarker":{"__symbolic":"error","message":"Function call not supported","line":40,"character":28},"redrawMarkers":{"__symbolic":"error","message":"Function call not supported","line":53,"character":29}}},{"__symbolic":"module","version":1,"metadata":{"reCenter":{"__symbolic":"error","message":"Function call not supported","line":8,"character":24},"reZoom":{"__symbolic":"error","message":"Function call not supported","line":15,"character":22},"createInstance":{"__symbolic":"error","message":"Function call not supported","line":21,"character":30},"createMarker":{"__symbolic":"error","message":"Function call not supported","line":40,"character":28},"redrawMarkers":{"__symbolic":"error","message":"Function call not supported","line":53,"character":29}}}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { MapStatus } from './enum/MapStatus'; | ||
export var loader = function (ak, offlineOpts, callback, protocol) { | ||
var realProtocol = protocol || location.protocol; | ||
var MAP_URL = realProtocol + "//api.map.baidu.com/api?v=2.0&ak=" + ak + "&callback=baidumapinit&s=" + (realProtocol === 'https:' ? 1 : 0); | ||
var win = window; | ||
var baiduMap = win['baiduMap']; | ||
if (baiduMap && baiduMap.status === MapStatus.LOADING) { | ||
return baiduMap.callbacks.push(callback); | ||
} | ||
if (baiduMap && baiduMap.status === MapStatus.LOADED) { | ||
return callback(); | ||
} | ||
win['baiduMap'] = { status: MapStatus.LOADING, callbacks: [] }; | ||
win['baidumapinit'] = function () { | ||
win['baiduMap'].status = MapStatus.LOADED; | ||
callback(); | ||
win['baiduMap'].callbacks.forEach(function (cb) { return cb(); }); | ||
win['baiduMap'].callbacks = []; | ||
}; | ||
var createTag = function () { | ||
var script = document.createElement('script'); | ||
script.type = 'text/javascript'; | ||
script.src = MAP_URL; | ||
script.onerror = function () { | ||
Array.prototype | ||
.slice | ||
.call(document.querySelectorAll('baidu-map div')) | ||
.forEach(function (node) { | ||
node.style.opacity = 1; | ||
}); | ||
document.body.removeChild(script); | ||
setTimeout(createTag, offlineOpts.retryInterval); | ||
}; | ||
document.body.appendChild(script); | ||
}; | ||
createTag(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{"loader":{"__symbolic":"error","message":"Function call not supported","line":4,"character":22}}},{"__symbolic":"module","version":1,"metadata":{"loader":{"__symbolic":"error","message":"Function call not supported","line":4,"character":22}}}] |
Oops, something went wrong.