TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Where'd The Water Go? Google Maps Water Pixel Detection With Canvas

51 pointsby erickerrover 11 years ago

8 comments

jameshartover 11 years ago
The assumptions here seem a little urban-centric. Maybe in a downtown area, the only places you shouldn&#x27;t show potential customers is in the middle of bodies of water; but what about a more rural or wild location - are you going to show a business that you can find them potential customers in the middle of fields? mountaintops? military testing ranges?<p>A better approach might be to use block-level census data to give you a probability density function to where you should plot your random made-up fake &#x27;potential customer&#x27; icons. Less risk that when a roadside truckstop in alaska brings up your site you wind up making the misleading claim that you can find them fifty customers within walking distance...
评论 #6406021 未加载
评论 #6402600 未加载
Doctor_Feggover 11 years ago
Or you could just use OpenStreetMap which, y&#x27;know, gives you access to the Actual Map Data rather than having to reverse-engineer it from the rendered image...
评论 #6402311 未加载
评论 #6402462 未加载
mmastracover 11 years ago
Interesting, although I&#x27;m not sure why they are setting an invalid value for Image.crossOrigin. The only valid values for this are &quot;anonymous&quot; and &quot;use-credentials&quot;. Setting an invalid value (like a URL) is treated as &quot;anonymous&quot;.<p>EDIT: And when running the jsfiddle demo, it looks like Google isn&#x27;t sending any CORS headers from the given map image, breaking the demo entirely:<p><a href="http://maps.googleapis.com/maps/api/staticmap?scale=2&amp;center=40.7300694,-74.0024224&amp;zoom=13&amp;size=1024x160&amp;sensor=false&amp;visual_refresh=true" rel="nofollow">http:&#x2F;&#x2F;maps.googleapis.com&#x2F;maps&#x2F;api&#x2F;staticmap?scale=2&amp;center...</a>
Someoneover 11 years ago
I don&#x27;t see the need to treat water different from earlier placed markers.<p>Here&#x27;s how I would hack this: whenever you place an icon, draw a slighty larger circular &#x27;lake&#x27; on top of that hidden canvas. That added lake prevents you from placing another icon in the neighborhood of that icon.
评论 #6402645 未加载
yesimahumanover 11 years ago
I did something funny like that a few years back trying to apply textures to roads for a game on top of the map. I normalized all the road colors to make it easy to pick out, then drew the texture on them with canvas (my memory is a little hazy here). It worked well, surprisingly.
eevoover 11 years ago
Cool article from a technical perspective.<p>I dont understand the business ask for drawing a map to show potential customers, then placing them randomly on the map. Why not just give rough volume numbers or something instead? It seems at least misleading.
评论 #6402291 未加载
评论 #6402282 未加载
udfalksoover 11 years ago
Would this not be much more easily solved by reverse geocoding each coordinate and seeing if google gives you a valid address for it?
评论 #6403039 未加载
davearelover 11 years ago
Great read