Just in case anyone has my obsession with mappy things. The above Bing map grid opens Google maps when grid marker so I can use Streetview to look for parking. Made a Chrome extension so that if I find somewhere I can then show exact location marked on Bing maps thing.
Bung 3 short files, with 2 obvious changes, in a directory with an icon:
manifest.json:
{
"manifest_version": 2,
"author": "<YOUR NAME>",
"name": "Streetview",
"version": "1.0",
"description": "Open Streetview location in Bing",
"background":
{
"scripts": ["background.js"]
},
"browser_action": {
"default_icon": "icon1.png"
},
"permissions": ["activeTab"]
}
background.js:
chrome.browserAction.onClicked.addListener(functio n(tab) {
chrome.tabs.executeScript(null, {file: "content.js"});
});
content.js:
var url = window.location.href;
var pos1 = url.indexOf("@",0)+1;
var pos2 = url.indexOf(",",pos1)+1;
var pos2 = url.indexOf(",",pos2);
var loc = url.substring(pos1, pos2);
url="<YOUR SITE MAP PAGE>.html?arg="+loc;
window.open(url,'_blank');
Enabling it covered here:
Getting Started Tutorial - Google Chrome
These extensions are very easy to do and best thing is they are pretty much same code in all major browsers.
- Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
- Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!
Reply to: Bing map API stuff
Collapse
You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:
- You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
- You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
- If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.
Logging in...
Previously on "Bing map API stuff"
Collapse
-
As a walking enthusiast I like Bing maps because they have OS map but Google Streetview is good for looking for places to park.
Grid sectors now have central marker that corresponds to my printed maps. Click on the marker brings up Google maps in a separate tab, centred on same area.
Moved see Bing/Street View Thread.
PS Seem small differences in different browsers, text moved a bit etc. Only real problems in Firefox which is rather slow to load and does not show letters on central markers. Still moves and zooms ok and opens Google though.Last edited by xoggoth; 11 February 2019, 11:18.
Leave a comment:
-
Finally - code here if any use
Updated version of grid marked map. Uses canvas to add notation to grid sectors as Bing pushpins are a bit limited. Click on sector to zoom in on it. Again to go back out. Map type change, drag and zoom still work.
Moved see Bing/Street View Thread.
If anyone not seen comment in light relief there's also a pushpin thing here to show footpath problems. Click pin to show brief description and photo. Click box to return. Ditto map change, zoom and drag.
Moved see Bing/Street View Thread.
Can't view source of these but for anyone not that au fait with websites etc, you can copy html and included js file using browser developer's tools.Last edited by xoggoth; 11 February 2019, 11:18.
Leave a comment:
-
As the pin has already been centred on the map and the infobox is centred above the pin by default, the solution is very simple:
var dy = info[n].getHeight() - 0.5 * map.getHeight() + 40;
if (dy>0)
{
map.setView({ centerOffset: new Microsoft.Maps.Point(0, dy), center: map.getCenter() });
}
Anyway, thanks again Fizzy Knickers.
Leave a comment:
-
Now give us an example in FORTRAN IV
Leave a comment:
-
FWIW, if you're using the Infobox class to display the info, there's some example code here of how to get the map to move when it's displayed so that it's fully on screen, but only if it's not: Dev Tip: Repositioning an Infobox | Maps Blog
Leave a comment:
-
Great, thanks NF!
I had done a botch taking y as proportional to latitude as it's only a fairly small area but nicer to do it properly.
Leave a comment:
-
The tryPixelToLocation method takes a second argument, reference, which specifies where the calculation should be relative to: 'control' meaning the top left corner of the map, 'page' meaning the top left corner of the HTML page, or the vaguely-specified 'viewport'; no idea from the docs what that actually is, but it's the default value: PixelReference Enumeration - Bing Maps | Microsoft Docs
So if you change that line to
Code:var location = map.tryPixelToLocation(point, Microsoft.Maps.PixelReference.control);
Leave a comment:
-
Bing map API stuff
Don't suppose anyone here has tried Bing maps API in jscript but worth a try.
Trying to set up a thing where local council can click on a map and see details & picture of any current footpath problems. All working fine except that the info boxes can go off top of screen, so need to scroll map down, ie centre on a more Northerly latitude, but can't get it to adjust properly.
Problem is , don't think it's my cockup, the methods just don't seem to work - see this simple bit of test code.
map.setView({center: new Microsoft.Maps.Location(lat[n],lon[n])});
alert("x");
var x = 0.5 * map.getWidth();
var y = 0.5 * map.getHeight();
var point = new Microsoft.Maps.Point(x, y);
var location = map.tryPixelToLocation(point);
map.setView({center: new Microsoft.Maps.Location(location.latitude,location .longitude)});
The map centres on the supplied lat/long in line 1. If I then get the centre of the map in pixels and convert that back to lat/long I should surely be at the same location, but it's way off, 500m or more.
Any ideas? Cheers.Tags: None
- Home
- News & Features
- First Timers
- IR35 / S660 / BN66
- Employee Benefit Trusts
- Agency Workers Regulations
- MSC Legislation
- Limited Companies
- Dividends
- Umbrella Company
- VAT / Flat Rate VAT
- Job News & Guides
- Money News & Guides
- Guide to Contracts
- Successful Contracting
- Contracting Overseas
- Contractor Calculators
- MVL
- Contractor Expenses
Advertisers
Contractor Services
CUK News
- Streamline Your Retirement with iSIPP: A Solution for Contractor Pensions Sep 1 09:13
- Making the most of pension lump sums: overview for contractors Sep 1 08:36
- Umbrella company tribunal cases are opening up; are your wages subject to unlawful deductions, too? Aug 31 08:38
- Contractors, relabelling 'labour' as 'services' to appear 'fully contracted out' won't dupe IR35 inspectors Aug 31 08:30
- How often does HMRC check tax returns? Aug 30 08:27
- Work-life balance as an IT contractor: 5 top tips from a tech recruiter Aug 30 08:20
- Autumn Statement 2023 tipped to prioritise mental health, in a boost for UK workplaces Aug 29 08:33
- Final reminder for contractors to respond to the umbrella consultation (closing today) Aug 29 08:09
- Top 5 most in demand cyber security contract roles Aug 25 08:38
- Changes to the right to request flexible working are incoming, but how will contractors be affected? Aug 24 08:25
Leave a comment: