Skip to content

Instantly share code, notes, and snippets.

View hanislovingit's full-sized avatar

Chuck Han hanislovingit

View GitHub Profile
@hanislovingit
hanislovingit / Bing-map-creation-api-point.js
Created April 22, 2015 01:52
Bing-map-creation-api-point
var point = new Microsoft.Maps.Point(x, y);
@hanislovingit
hanislovingit / Mapbox-creation-api-latLngBounds.js
Created April 22, 2015 01:49
Mapbox-creation-api-latLngBounds
var extent = L.latLngBounds(southWest, northEast);
@hanislovingit
hanislovingit / Bing-map-creation-api-locationRect.js
Created April 22, 2015 01:47
Bing-map-creation-api-locationRect
var extent = new Microsoft.Maps.LocationRect(center, width, height);
//or using the static method "fromCorners"
var extent = Microsoft.Maps.LocationRect.fromCorners(northWestLocation, southEastLocation);
@hanislovingit
hanislovingit / Mapbox-creation-api-latLng.js
Created April 22, 2015 01:40
Mapbox-creation-api-latLng
var location = L.latLng(latValue, lngValue);
@hanislovingit
hanislovingit / Bing-map-creation-api-location.js
Created April 22, 2015 01:38
Bing-map-creation-api-location
var location = new Microsoft.Maps.Location(latValue, lngValue);
@hanislovingit
hanislovingit / Mapbox-switch-map-view-types.js
Last active August 29, 2015 14:19
Mapbox-switch-map-view-types
var mapboxSatelliteLayer = L.mapbox.tileLayer('satelliteMapboxMapId'); // default map
var mapboxStreetLayer = L.mapbox.tileLayer('streetMapboxMapId');
function (val) {
switch (val) {
case '0':
if (_map.hasLayer(mapboxSatelliteLayer)) {
_map.removeLayer(mapboxSatelliteLayer);
}
_map.addLayer(mapboxStreetLayer);
@hanislovingit
hanislovingit / Bing-map-switch-map-view-type.js
Created April 20, 2015 04:01
Bing-map-switch-map-view-type
var MM = Microsoft.Maps;
function (val) {
switch (val) {
case '0':
map.setView({ mapTypeId: MM.MapTypeId.road });
break;
case '1':
map.setView({ mapTypeId: MM.MapTypeId.aerial, labelOverlay: MM.LabelOverlay.hidden });
break;
@hanislovingit
hanislovingit / Mapbox-creation-api-map-class.js
Created April 20, 2015 03:47
Mapbox-creation-api-map-class
L.mapbox.accessToken = 'yourMapboxAccountAccessTokenString';
var mapOptions = {
zoomControl: false,
center: initExtent.center().toMapboxLatLng()
maxZoom: 20 // This overrides any maxZoom set on map layers
};
var map = L.mapbox.map(containerDivId, "yourMapboxMapId", mapOptions);
@hanislovingit
hanislovingit / Bing-map-creation-api-map-class.js
Last active August 29, 2015 14:19
Bing-map-creation-api-map-class
var viewOptions = {
credentials: "yourBingMapKeyString",
bounds: <LocationRect> object,
showMapTypeSelector: false,
mapTypeId: Microsoft.Maps.MapTypeId.aerial,
labelOverlay: Microsoft.Maps.LabelOverlay.visible,
showDashboard: false,
enableSearchLogo: false
};
@hanislovingit
hanislovingit / Mapbox-handling-events.js
Last active August 29, 2015 14:19
Mapbox-handling-events
// add an event handler to a Marker object
var marker = L.marker(<LatLng> object);
marker.on('mouseover', function (event) {
// some code here to handle mouseover event on a marker object
});
// remove an event handler
marker.off('mouseover');